It's not possible to use composer to require the colorbox module at this time, because it requires "jackmoore/colorbox" in composer.json, but that is not a composer package--the repo on GitHub does not have a composer.json. The library should be installed some way other than composer, and that line should be removed for this module to be compatible with composer.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bmcclure created an issue. See original summary.

bmcclure’s picture

Issue summary: View changes
rossb89’s picture

Add something like this to your repositories section in composer.json and it works fine.

e.g.

"repositories": [
        {
            "type": "package",
            "package": {
                "name": "jackmoore/colorbox",
                "version": "master",
                "type": "drupal-library",
                "dist": {
                    "url": "https://github.com/jackmoore/colorbox/archive/1.x.zip",
                    "type": "zip"
                },
                "require": {
                    "composer/installers": "^1.0.21"
                }
            }
        }
]
webcultist’s picture

But it's true that it's not possible to load it that way out of the box. Better remote the dependency and document it on the page.

heddn’s picture

Right now the latest version of colorbox I can pull down with composer is 1.1, before the requirements for the js library was added to it. Things just fail.

http://cgit.drupalcode.org/colorbox/tree/composer.json?h=8.x-1.2-- (no no longer functional)
http://cgit.drupalcode.org/colorbox/tree/composer.json?h=8.x-1.1++ (works)

heddn’s picture

Status: Active » Needs review
FileSize
745 bytes
heddn’s picture

#2714631: Consider composer library support I think is what broke things? I've been involved in a few of these composer.json issues across contrib now. There isn't a good way to test the composer json until it is committed.

If we want to provide guidance on how to use composer to download the required js dependency, see how that was done on https://www.drupal.org/project/file_browser. There's an example gist added to the project page that walks things through.

MaskOta’s picture

So in order for composer to be able to find the dependant library it needs to be available on https://packagist.org/search/?q=jackmoore ?

heddn’s picture

re #8: correct. Also to note, the path that bower wants to put the files is not at 'colorbox', but rather 'jquery-colorbox'. So if this does get loaded on packagist, it will probably get loaded in similar manner. Perhaps this should be considered an a BC layer added to check in both locations.

  • frjo committed 49b4ccb on 8.x-1.x authored by heddn
    Issue #2814045 by heddn: composer.json issue in latest dev and 1.2.0
    
frjo’s picture

Status: Needs review » Fixed

Committed #8 to 8.x-1.x. Thanks for the contribution!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jelhan’s picture

A release including fix would be nice.

rutiolma’s picture

+1 for a new release.

csedax90’s picture

+1, we need a new stable release

frjo’s picture

New release is out.

scottsawyer’s picture

Here is how I am handling git libraries that don't have a composer.json:

In my root composer.json, under "repositories":

        "colorbox": {
             "type": "package",
             "package": {
                  "name": "jackmoore/colorbox",
                  "version": "dev-master",
                  "type": "drupal-library",
                  "source": {
                       "url": "https://github.com/jackmoore/colorbox.git",
                       "type": "git",
                       "reference": "1.6.4"
                  },
                  "require": { "composer/installers": "~1.0" }
             }
        }

At the time of this comment, the current tag is 1.6.4.

To install the package, I just run composer require jackmoore/colorbox and it installs colorbox in web/libraries/colorbox

Hope this helps someone.

karolus’s picture

@scottsawyer,

Thanks for this post--I added it to my composer.json file, but when running composer require jackmoore/colorbox, get this error:

  [InvalidArgumentException]                                                                
  Could not find package jackmoore/colorbox at any version for your minimum-stability (dev  
  ). Check the package spelling or your minimum-stability   

This happens regardless of my minimum stability settings. Anything else you did?

I did find a solution that worked here.