composer: Requirements error says 'but it conflicts with another require' without saying what the problem actually is
My composer.json
:
{
"name": "drupal/git-clone-project",
"description": "TODO",
"type": "project",
"license": "GPL-2.0-or-later",
"homepage": "https://www.drupal.org/project/drupal",
"support": {
"docs": "https://www.drupal.org/docs/user_guide/en/index.html",
"chat": "https://www.drupal.org/node/314178"
},
"repositories": [
{
"type": "path",
"url": "repos/drupal",
"options": {
"symlink": true
}
},
{
"type": "path",
"url": "repos/drupal/core"
},
{
"type": "path",
"url": "repos/drupal/composer/Plugin/ProjectMessage"
},
{
"type": "path",
"url": "repos/drupal/composer/Plugin/VendorHardening"
},
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"composer/installers": "^1.9",
"drupal/core-composer-scaffold": "^8.9",
"drupal/drupal": "*",
"drush/drush": "^10.3",
"symfony/var-dumper": "^5.1"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
},
"extra": {
"drupal-scaffold": {
"locations": {
"web-root": "web/"
}
},
"installer-paths": {
"web/core": [
"type:drupal-core"
],
"web/libraries/{$name}": [
"type:drupal-library"
],
"web/modules/contrib/{$name}": [
"type:drupal-module"
],
"web/profiles/contrib/{$name}": [
"type:drupal-profile"
],
"web/themes/contrib/{$name}": [
"type:drupal-theme"
],
"drush/Commands/contrib/{$name}": [
"type:drupal-drush"
],
"web/modules/custom/{$name}": [
"type:drupal-custom-module"
],
"web/themes/custom/{$name}": [
"type:drupal-custom-theme"
]
}
}
}
Additionally need to do the following in the project folder before installing with Composer:
mkdir repos
cd repos
git clone --branch 9.2.x https://git.drupalcode.org/project/drupal.git
Output of composer diagnose
:
Checking composer.json: WARNING
require.drupal/drupal : unbound version constraints (*) should be avoided
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0 87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B 0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: You are not running the latest stable version, run `composer self-update` to update (2.0.3 => 2.0.4)
Composer version: 2.0.3
PHP version: 7.4.2
PHP binary path: /Applications/MAMP/bin/php/php7.4.2/bin/php
OpenSSL version: OpenSSL 1.0.2o 27 Mar 2018
cURL version: 7.65.1 libz 1.2.8 ssl OpenSSL/1.0.2o
zip extension: OK
When I run this command:
composer require -W drupal/core-dev ^9.2
I get the following output:
Running composer update drupal/core-dev --with-all-dependencies
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires drupal/drupal *, found drupal/drupal[9.2.x-dev] but it conflicts with another require.
And I expected this to happen:
I need to be told what the ‘another require’ actually is, otherwise I can’t understand or fix the problem.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 12
- Comments: 24 (16 by maintainers)
Commits related to this issue
- Re-organized PoolOptimizer - reverting #9620 to fix #9393 — committed to Toflar/composer by Toflar 6 months ago
- Failing test to outline problem in #9393 — committed to Toflar/composer by Toflar 6 months ago
The simple workaround here should be to run the update command with drupal/drupal added as well, which means running require without an update first and then manually updating:
It also works from scratch if I add
drupal/core-dev
to the composer.json (with version *) and then docomposer update
.Bah, debugging this is super time-consuming. But here’s what I’ve found out so far (gotta stop for today):
optimizeByIdenticalDependencies()
which I’ve originally contributed works correctly. E.g.drupal/core
10.2.0.0
gets marked as to keep here: https://github.com/composer/composer/blob/8e62977cb5de315d5190c021a2b2bb4e59ee2f4f/src/Composer/DependencyResolver/PoolOptimizer.php#L243optimizeImpossiblePackagesAway()
) you will get a resolvable set of dependencies.git blame
points to https://github.com/composer/composer/pull/9620So seems to be related to the locked packages logic.
Yeah sorry I have no clue what’s going on there. It’s quite a pain as I cannot easily navigate the drupal packages’ dependencies as with those that are on packagist.org… But from what I gather the issue is that drupal/core_event_dispatcher requires drupal/core ^9.3, and drupal/core-recommended requires drupal/core ^10, so that’s the conflict.
I don’t know why it does not show this in the partial update though, that is very odd, but at least doing a full update shows you the problem. This happens somehow with complex setups like core-recommended which add indirection. If you change the require to drupal/core ^10 instead of core-recommended then it works. So that might allow us to build a smaller repro case to try and understand this…
I did:
same result as before.
I then tried:
and that worked!!!
Thanks!