COMPOSER V2: PROBLEMS WHEN UPDATING DRUPAL

Today I had a little problem trying to update a website in Drupal 8.

This website has always had a composer in version 1, and I have already updated it several times. But I'm just starting to use docker images for local development with composer v2.

Today I got the surprise that I can't update this particular site using composer v2 (it's a good practice to always update on a copy on your local machine to check that everything works fine and not to crash the client site on the production server).

I get the following error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - drupal-composer/drupal-scaffold[2.5.0, ..., 2.6.1] require composer-plugin-api ^1.0.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
    - Root composer.json requires drupal-composer/drupal-scaffold ^2.5 -> satisfiable by drupal-composer/drupal-scaffold[2.5.0, ..., 2.6.1].

You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.

In the end, I have not been able to fix it, and the only thing I could do is to revert the composer and go back to using v1. Mostly because the client pays me to update Drupal, not to change server configurations. The "quick fix" is to leave composer v1 for the time being.

This is done with this command.

composer self-update --1

This is a nuisance because v2 is much faster, but apparently, it is not always compatible with older sites in D8.

EDIT: I finally solved it.

In my case, it was taking the composer.json from https://github.com/drupal-composer/drupal-project and manually going over what things were different. Since I had problems with dependencies.

My colleague David (akalam) recommended me this article from Acquia where they explain how to update "drupal/core-composer-scaffold". It is highly recommended reading to solve this problem.

Tags

Have Any Project in Mind?

If you want to do something in Drupal maybe you can hire me.

Either for consulting, development or maintenance of Drupal websites.