Deploy problem - non-zero return code(...) You are using Composer 2

I have a problem with deploy. I had a composer 2.0^ on vagrant but I made a downgrade to 1.6.0.

non-zero return code
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Warning: The lock file is not up to date with the latest changes in
composer.json. You may be getting outdated dependencies. It is recommended
that you run `composer update` or `composer update <package name>`.
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.0.0] but it does not match the constraint.
  Problem 2
    - composer/installers v1.6.0 requires composer-plugin-api ^1.0 -> found
composer-plugin-api[2.0.0] but it does not match the constraint.
    - soberwp/controller 2.1.1 requires composer/installers ^1.0 ->
satisfiable by composer/installers[v1.6.0].
    - soberwp/controller is locked to version 2.1.1 and an update of this
package was not requested.

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. (...)

After update and change .main.yml

composer_keep_updated: false
composer_version: '1.6.0'
 - { name: hirak/prestissimo }

server.yml and dev.yml to:

{ role: composer, tags: [composer], composer_version: '1.6.0', composer_keep_updated: false }

I push changes to repo and make a provision

ansible-playbook server.yml -e env=production

But still I got an above error.
I can’t update composer to 2.0.0 because composer-plugin-api is not compatible.

How to resolve it ?

When you want to stay with composer 1, you have to take into account that the composer lock file has been updated to dependencies that only work with composer 2. The easiest way would be just removing the composer lock file and installing again using composer 1 - I know, I know, a lockfile has a purpose, but usually it should just work this way, test the site afterwards.

If you want to use the new composer 2, you have to update your Bedrock site, as recent Bedrock uses composer dependencies that are compatible with composer 2. Create a new Bedrock project and then overwrite your existing project with these files, then resolve conflicts/merge the changes. Usually it is the composer.json that you have to merge as it contains your plugins and some meta data.

1 Like

Thanks, I’ve updated composer to 2.0 and bedrock. That was a lot of changes in my environment. Downgrade python, update ansible, composer, bedrock + mismatch SSH keys… Crazy day

I have a similar problem, and as @Jacek I can’t update composer to 2.0.0.

@strarsis could you please articulate your msg for a not super expert user?
I would like to stay with composer 1, do I need to delete the /site/composer.lock and then from the /site/ directory run composer update.

is this right?

any other steps that I have to do?

It depends on your goal: Do you want to update your Bedrock site to be compatible with the new composer 2 or do you want to keep composer 1 support?

I am happy either way, as far as it works, I just need to push this live, it needs to be live on Wednesday, and I am stuck with this annoying error.

I tried to delete the /site/composer.lock and then from the /site/ directory run composer update, but it didn’t help.

any advice or suggestions on how I could fix this, it would be great :pray:

Then I recommend using the new composer 2 in favour of composer 1 backwards compatiblity:

  1. Create a new, empty Bedrock project.
  2. (Assuming you are already using a VCS like git for your own Bedrock project) Copy all the files from the newly created Bedrock project (except vendor/) over your own Bedrock project, overwrite everything.
  3. Using the VCS you can now resolve any conflicts and restore your own plugins and metadata (author and so on) in the composer.json.
  4. Remove the existing composer.lock.
  5. Install the composer dependencies and regenerate the composer.lock by invoking composer install.
  6. Test the whole site, but usually it should just work. A common issue can be the filename case sensitivity sometimes (on native Windows file systems).

thanks for this @strarsis, at the end I was able to finally deploy following this > Deploy failed - Composer

but reading your msg, I am wondering if this is a way to update bedrock?
I was thinking to update trellis and bedrock at one point today (even if I started this project just a couple of weeks ago, so they are not very out of date), but then I realised that I don’t know what it the best way to do this.

can I use this workflow to update bedrock some of my old trellis/bedrock websites?

Yes, you can update Bedrock (and Trellis). Though from there on you need to use the new composer 2 as composer 1 wouldn’t be compatible with the dependencies.

When you update Trellis you should test the new configuration on a staging server first.

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.