wikimedia / composer-merge-plugin

Merge one or more additional composer.json files at Composer runtime
MIT License
934 stars 159 forks source link

Error due to conflicting global (1.3.1) and project (1.4.0) version #138

Open schmunk42 opened 7 years ago

schmunk42 commented 7 years ago

I have 1.3.1 installed globally and no require in my project.

While update runs fine, I noticed that in my composer.lock I get "forcibly" injected version 1.4.0 of this plugin. When running composer show it shows the the plugin, but composer why ... claims the package is unknown.

When running install I get this error:

[Symfony\Component\Debug\Exception\FatalThrowableError]                         
  Call to undefined method Wikimedia\Composer\Merge\ExtraPackage::mergeDevInto()

My current workaround is to limit installations to 1.3 in my root composer.json

    "require": {
        "wikimedia/composer-merge-plugin": "~1.3.1"
    },

Does the plugin needs to inject itself at all? If so, I think it would be better to inject its current version.

schmunk42 commented 7 years ago

Stacktrace:

Fatal error: Uncaught Error: Call to undefined method Wikimedia\Composer\Merge\PluginState::shouldMergeDev() in phar:///opt/bin/composer.phar/src/Composer/Plugin/PluginManager.php(194) : eval()'d code:300
Stack trace:
#0 [internal function]: Wikimedia\Composer\MergePlugin_composer_tmp2->onDependencySolve(Object(Composer\Installer\InstallerEvent))
#1 phar:///opt/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(170): call_user_func(Array, Object(Composer\Installer\InstallerEvent))
#2 phar:///opt/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(134): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Installer\InstallerEvent))
#3 phar:///opt/bin/composer.phar/src/Composer/Installer.php(458): Composer\EventDispatcher\EventDispatcher->dispatchInstallerEvent('pre-dependencie...', true, Object(Composer\DependencyResolver\DefaultPolicy), Object(Composer\DependencyResolver\Pool), Object(Composer\Repository\CompositeRepository), Object(Composer\DependencyResolver\Request))
#4 ph in phar:///opt/bin/composer.phar/src/Composer/Plugin/PluginManager.php(194) : eval()'d code on line 300
bd808 commented 7 years ago

Global installation is not a considered or expected use case. Composer-merge-plugin is intended to be used cooperatively with the root composer.json for any particular deployment. What is your expected behavior with the plugin installed globally?

schmunk42 commented 7 years ago

Because we're using it in most of our projects we added it to our development environment (Docker images). We're usually working with build tools from this image, including composer. Some other plugins only work in global mode, I just did not saw anything stating that you should not do this :) I also thought it would save one run of dependency resolution, if it is already there.

So, maybe something worth adding to the docs... or disallow global installation or throw a warning.