Can't install CiviCRM in Drupal 9 with Composer if Drush is installed
One of the first things I do when starting a new Drupal 9 site, is adding Drush with Composer to be able to install Drupal.
Following the very detailed and thorough documentation page Install CiviCRM on Drupal 8/9, I get a "Your requirements could not be resolved" error:
$ composer create-project drupal/recommended-project
$ cd recommended-project
$ lando init --source cwd --recipe drupal9 --webroot web --name drupal9
$ lando start
$ lando composer require drush/drush
$ lando composer config extra.enable-patching true
$ lando composer config minimum-stability dev
$ lando composer require civicrm/civicrm-{core,packages,drupal-8}
Using version ^5.44 for civicrm/civicrm-core
Using version ^5.44 for civicrm/civicrm-packages
Using version ^5.44 for civicrm/civicrm-drupal-8
./composer.json has been updated
Running composer update civicrm/civicrm-core civicrm/civicrm-packages civicrm/civicrm-drupal-8
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- civicrm/civicrm-core[5.44.0, ..., 5.45.x-dev] require symfony/finder ~3.0 || ~4.4 -> found symfony/finder[v3.0.0-BETA1, ..., 3.4.x-dev, v4.4.0-BETA1, ..., 4.4.x-dev] but the package is fixed to v5.4.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- Root composer.json requires civicrm/civicrm-core ^5.44 -> satisfiable by civicrm/civicrm-core[5.44.0, 5.44.x-dev, 5.45.x-dev].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
If I remove Drush with lando composer remove drush/drush
and run the command again, CiviCRM is installed as expected. Also, if I add Drush after an older CiviCRM version has been installed (for example 5.42
) I can still update to the latest version, 5.44
. So it seems like Drush locks some version constraints too tightly, if it is installed first.