Conflict handling with require --no-update-dev
My minimized composer.json:
{
"require-dev": {
"cracksalad/gearman-ide-helper": "^1.0"
}
}Note: This dependency conflicts with ext-gearman, which is installed on the target platform.
Now, I want to deploy this package together with its composer.lock to the target platform without dev dependencies. In addition, I want to add a single library, which e.g. depends on the extension which was not installed locally but might also be completely independent.
When I run this command:
composer install --no-dev # works fine (output skipped)!
composer require <anything> --no-update-devNote:
- Even when adding
--no-install, the result stays the same. With--no-updateit works, but both are not intended to be used here of course. - When swapping the two CLI statements, the
composer require [...]fails with the same output/error. - When swapping the two statements and adding
--no-update, thecomposer require [...]is successful, but thecomposer install [...]will not install the added library, since the composer.json and composer.lock do not match anymore.
I get the following output:
./composer.json has been updated
Running composer update <anything>
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- ext-gearman is present at version 2.2.1 and cannot be modified by Composer
- cracksalad/gearman-ide-helper is locked to version v1.1.0 and an update of this package was not requested.
- cracksalad/gearman-ide-helper v1.1.0 conflicts with ext-gearman *.
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php.ini
[...]
- /etc/php.d/40-gearman.ini
[...]
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-gearman` to temporarily ignore these required extensions.
Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.And I expected this to happen:
It should just have added the required library as if it was part of the composer.json and composer.lock already, since it does not have to do with the conflict.
Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.
This confuses me. Why do I have to resolve those problems, when composer install --no-dev works totally fine?
To me, require and install show inconsistent behavior here, which is the bug I want to report. I actually do not know, which of them should be modified. I would suggest to change require rather than install.
Source: composer/composer