drupal-composer / drupal-packagist

:package: Drupal Packagist server to automatically build package information from projects on drupal.org
http://packagist.drupal-composer.org
28 stars 4 forks source link

adding repositories.drupal to global composer config is ignored; local is used #49

Closed ghost closed 8 years ago

ghost commented 8 years ago

If I add packagist repo to global config

composer global config repositories.drupal composer https://packagist.drupal-composer.org
cat ~/.composer/composer.json
    {
        "repositories": {
            "drupal": {
                "type": "composer",
                "url": "https://packagist.drupal-composer.org"
            }
        }
    }

any subsequent package require fails

cd <drupalroot>
composer require  drupal/big_pipe:8.1.0-beta3

    ./composer.json has been updated
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Your requirements could not be resolved to an installable set of packages.

      Problem 1
        - The requested package drupal/big_pipe could not be found in any version, there may be a typo in the package name.

    Potential causes:
     - A typo in the package name
     - The package is not available in a stable-enough version according to your minimum-stability setting
       see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

    Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

    Installation failed, reverting ./composer.json to its original content.

But if I add the repo locally

composer config repositories.drupal composer https://packagist.drupal-composer.org
cat ./composer.json
    ...
      "repositories": {
        "drupal": {
          "type": "composer",
          "url": "https://packagist.drupal-composer.org"
        }
      }
    }

all packages install with no issue

composer require  drupal/big_pipe:8.1.0-beta3
    ./composer.json has been updated
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
      - Installing drupal/big_pipe (8.1.0-beta3)
        Loading from cache

    > Drupal\Core\Composer\Composer::vendorTestCodeCleanup
    Writing lock file
    Generating autoload files
    > Drupal\Core\Composer\Composer::preAutoloadDump
    > Drupal\Core\Composer\Composer::ensureHtaccess

Iiuc, global configs should be respected.

Is there additional config needed here? or is the use of global config broken?

webflo commented 8 years ago

The global repo config is not related to your project configuration. Global repos don't apply to the project configuration, thats the default behaviour of composer.

ghost commented 8 years ago

Hm. I'd read this

https://getcomposer.org/doc/03-cli.md#composer-home-config-json

    You may put a config.json file into the location which COMPOSER_HOME points to.
    Composer will merge this configuration with your project's composer.json when you
    run the install and update commands.

    This file allows you to set repositories and configuration for the user's projects.

    In case global configuration matches local configuration, the local configuration in
    the project's composer.json always wins.

to suggest setting

export COMPOSER_HOME="${HOME}/.composer"

is supposed to do the trick.

It apparently doesn't.

Perhaps I've misread, or, drupal8's project is for some reason insensitive to it.

webflo commented 8 years ago

Sounds like a composer bug, could you open a issue against composer directly?

tobiasbaehr commented 8 years ago

Your schema is wrong. (Or just the filename ;-)) It should looks like a normal composer.json.

~/.composer/config.json:

 {
   "repositories": [
   {
     "type": "composer",
     "url": "https://packagist.drupal-composer.org"
   }
   ]
 }
ghost commented 8 years ago

solved at https://github.com/composer/composer/issues/4909