composer / installers

A Multi-Framework Composer Library Installer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue installing library with their own composer.json

jurgenhaas opened this issue · comments

Used versions:

  • PHP: 7.0
  • composer: 1.8.6
  • composer/installers: 1.7.0

Context: Drupal project

Here is an extract of my composer.json:

{
   ...
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        {
            "type": "package",
            "package": {
                "name": "ckeditorplugin/codesnippet",
                "type": "drupal-library",
                "version": "master",
                "dist": {
                    "type": "zip",
                    "url": "https://download.ckeditor.com/codesnippet/releases/codesnippet_4.5.11.zip",
                    "reference": "master"
                }
            }
        },
        {
            "type": "package",
            "package": {
                "name": "harvesthq/chosen",
                "type": "drupal-library",
                "version": "master",
                "dist": {
                    "type": "zip",
                    "url": "https://github.com/harvesthq/chosen/releases/download/v1.8.7/chosen_v1.8.7.zip",
                    "reference": "master"
                }
            }
        }
    ],
    "require": {
        "ckeditorplugin/codesnippet": "master",
        "harvesthq/chosen": "^1.6",
...
    },
    "extra": {
        "installer-paths": {
...
            "web/libraries/{$name}": [
                "type:drupal-library"
            ],
        },
    }
}

Expectation: both libraries should be installed in web/libraries but only codesnippet lands there and the chosen library goes into the vendor directory. I guess this is because that library comes with a composer.json which declares the type as library which seems to overwrite my type drupal-library.

I've then tried to add "harvesthq/chosen" to extra / installer-paths / web/libraries array but that made no difference.

My question is: how do I get the chosen library into the web/libraries path?

Further investigation uncovered more details:

The installation work fine if the version string in repositories/package and in require are exactly the same. But only if really the same.

However, if the version string is master, it doesn't work and always stores the library in vendor directory.

Also, if the drupal-library is required by another package (not by the root project), it will always be installed in vendor and not in the installer path defined in extras.

Hope, those further aspects help to identify and fix the issue.