Drupal ^8.8 || ^9 Upgrade - Resolving Composer 1 - 2 Issues | Tutorial

Resolving Composer 1 and 2 Issues

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; and
  • drupal-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.

  1. Back up database and code. As an additional precaution, I took a snapshot of my server.
  2. Set appropriate permissions on the .composer/cache/ install directory.
  3. Remove Drupal Console (This has too many D9 issues for my liking)
  4. Remove drupal-composer/drupal-scaffold.
  5. Update composer/installers and cweagans/composer-patches.
  6. Update Drupal core and contributed modules in preparation for upgrading to Drupal 9
  7. Upgrade Drupal, contributed modules and any Symphony requirements not triggered by the update process.
  8. Update database.
  9. 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:

Image
Composer synch error

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

  1. 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.

Related Articles

Drupal 8: Apache Solr Search Setup

Site Location

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.