The Topic: Upgrading Drupal 8.9.20 to 9.3.0 - resolving globally installed Composer 1 and 2 issues.
In a previous article we looked at upgrading 8.9.19 to 9.2.6. As part of that process we looked at upgrading Composer 1 to 2. Drupal 9 requires Composer 2.
I have other Drupal 8 sites running on the same server. Composer is installed globally. The Drupal 8 sites now have Composer and Drupal Composer plugins that are expecting to use Composer 1 API. Composer will not work in these environments. We will run into issues relating to
composer/installers
;cweagans/composer-patches
;drupal/console-extend -plugin
; anddrupal-composer/drupal-scaffold
plugins.
On running any Composer command the following is outputted:
The "composer/installers" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.1.0"). You may need to run composer update with the "--no-plugins" option. The "cweagans/composer-patches" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.1.0"). You may need to run composer update with the "--no-plugins" option. The "drupal/console-extend-plugin" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.1.0"). You may need to run composer update with the "--no-plugins" option. The "drupal-composer/drupal-scaffold" plugin was skipped because it requires a Plugin API version ("^1.0.0") that does not match your Composer installation ("2.1.0"). You may need to run composer update with the "--no-plugins" option.
You could also see output such as:
Your lock file does not contain a compatible set of packages. Please run composer update. Problem 1 - composer/installers is locked to version v1.6.0 and an update of this package was not requested. - composer/installers v1.6.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.1.0] but it does not match the constraint. Problem 2 - cweagans/composer-patches is locked to version 1.6.6 and an update of this package was not requested. - cweagans/composer-patches 1.6.6 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.1.0] but it does not match the constraint. Problem 3 - drupal-composer/drupal-scaffold is locked to version 2.6.1 and an update of this package was not requested. - drupal-composer/drupal-scaffold 2.6.1 requires composer-plugin-api ^1.0.0 -> found composer-plugin-api[2.1.0] but it does not match the constraint. Problem 4 - drupal/console-extend-plugin is locked to version 0.9.4 and an update of this package was not requested. - drupal/console-extend-plugin 0.9.4 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.1.0] but it does not match the constraint. Problem 5 - composer/installers v1.6.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.1.0] but it does not match the constraint. - drupal/console 1.9.5 requires composer/installers ~1.0 -> satisfiable by composer/installers[v1.6.0]. - drupal/console is locked to version 1.9.5 and an update of this package was not requested.
This article looks at resolving the Composer 1 / 2 issues in preparation for upgrading Drupal 8.9.20 to 9.3.0.
The Process
Below are the steps I took.
- Back up database and code. As an additional precaution, I took a snapshot of my server.
- Set appropriate permissions on the .composer/cache/ install directory.
- Remove Drupal Console (This has too many D9 issues for my liking)
- Remove
drupal-composer/drupal-scaffold
. - Update
composer/installers and cweagans/composer-patches
. - Update Drupal core and contributed modules in preparation for upgrading to Drupal 9
- Upgrade Drupal, contributed modules and any Symphony requirements not triggered by the update process.
- Update database.
- Check for missing elements in
composer.json
file.
2 - Set appropriate permissions on the .composer/cache/
install directory.
Step 1 should be self-explanatory. During my process, after a few --dry-runs I attempted a Composer update. The following error was shown:
Difficult to read, I know. Basically Composer was trying to clone to the .composer/cache directory in $home. Checking permissions on .composer/cache revealed root ownership. I changed the ownership to $USER:$USER.
Remove and update plugins
Now we want to remove what is not required and update what is.
Remove Drupal Console
- Remove Drupal Console: composer remove drupal/console --no-update
Upgrade composer/installers
and cweagans/composer-patches
:
- composer require composer/installers:^1.9 cweagans/composer-patches:^1.7 --no-update - this updates
composer.json
file. - composer update composer/installers cweagans/composer-patches --with-all-dependencies --dry-run - this will show if there are errors. If none, proceed to next step
- composer update composer/installers cweagans/composer-patches --with-all-dependencies
Remove drupal-composer/drupal-scaffold
- composer remove drupal-composer/drupal-scaffold --no-update
Run composer install. This will remove Drupal Console and drupal-composer/drupal-scaffold
You should now be in a position to upgrade Drupal core and contributed modules in preparation for the Drupal 9 upgrade.
This article gives steps on the full D8 - D9 upgrade process.
Add new comment