Roots Discourse

Deploy failed - Composer

Fresh new website using trellis/bedrock/sage 9.0.9.

On local all ok, I provisioned the staging, and then I tried to deploy, but with no success.

I have this annoying bug

non-zero return code
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
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.
fatal: [142.93.41.40]: FAILED! => {"changed": true, "cmd": ["composer", "install", "--no-ansi", "--no-dev", "--no-interaction", "--no-progress", "--optimize-autoloader", "--no-scripts", "--classmap-authoritative"], "delta": "0:00:00.337329", "end": "2021-02-06 00:53:26.459614", "rc": 2, "start": "2021-02-06 00:53:26.122285", "stderr_lines": ["Installing dependencies from lock file", "Verifying lock file contents can be installed on current platform.", "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."], "stdout": "", "stdout_lines": []}

I spent one day to try to figure out what it is going on and how to fix this, but no luck. (i saw similar post with the same problem, but they didn’t help me)

my impression is that I need to be sure that my vagrant box run composer 1.6, because it seems a problem with composer 2.

i tried with this https://github.com/roots/trellis/issues/1245#issuecomment-716165875

I updated the main.yml with

composer_keep_updated: false
composer_version: '1.6.0'

and I updated 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, but I still have the problem.

I SSH into the vagrant box. From the /trellis directory, I run vagrant ssh, I checked what version of composer is installed with composer --version but I still have “Composer version 2.0.9 2021-01-27 16:09:27” (same thing on my staging enviroment)

what can I do?
I am really struggling with this, could somebody point me in the right direction?

Maybe not the fix you are looking for but: You could install Composer 2 on your local machine and make sure that you can run composer update and composer install there. It might be that you have to update some dependencies for it to work but Composer 2 is here to stay so… :slight_smile:

If you dont want to update Composer globally you can put composer.phar in your projects folder and use that when running composer. Something like php composer.phar update If I remember it correct (writing this on my phone).

thanks @folbert, I think that I had composer 2 in the first instance, but I downgraded again to 1 because it failed to resolve dependencies because I guess some plugins still rely on composer 1.
in the meantime, I finalised the website with composer 1, so I am ready to push it live (it needs to be live on Wednesday so I am running out of time, I am stuck here since 2 days :cold_face:).
I can give another go with composer 2, but I am scared because as I said it is all done and ready to go live. (I am not sure if I will have enough time to find/replace other plugins that work with composer 2)

@JordanC26 / @Twansparant I saw your topic (Trellis 1.7.0 with Composer 1.x) , and I think that I have the same problem. (sorry if I drag you here, but that post has the comments closed).
did you find a workaround with that?
do you have any suggestion?

thanks

Here’s what I did in the end:

  1. Update Composer locally to version 2+
  2. Remove the lines from /group_vars/all/main.yml:
composer_global_packages:
{ name: hirak/prestissimo }
  1. SSH into your vagrant box and update Composer to version 2:

composer self-update or:
composer self-update --2

  1. Remove your site/composer.lock file.
  2. Make sure you update the following dependencies in your site/composer.json:
"composer/installers": "^1.9",
"vlucas/phpdotenv": "^5.2"

and make sure you’ve got at least Bedrock version 1.14.3 or higher.

  1. Run rm -rf vendor && composer install from the site dir and push your git commits.

  2. Check your theme’s composer.json and update:

"composer/installers": "^1.9"
  1. SSH into your remote server and check for the current composer version: composer --version.
    If neccessary update to version 2+:

composer self-update or:
composer self-update --2

  1. Deploy your changes to the remote server.

This worked for me for at least 8 running projects!

thanks @Twansparant, I followed this, but it didn’t work for me :sob: :sob: :sob:

I updated composer locally to version 2 (Composer version 2.0.9 2021-01-27 16:09:27)

My /group_vars/all/main.yml is like this

if I SSH into my vagrant box and I check the composer --version I can see (Composer version 2.0.9 2021-01-27 16:09:27)

my site/composer.json is like

and my theme’s composer.json is

I SSH into staging remote server and I can see (Composer version 2.0.9 2021-01-27 16:09:27)

of course, I committed all these changes and I tried to re-provision the server and re-deploy multiple times, but with no luck.

I don’t know what else I can try :sob:

this is the error that I have (with composer 1 or composer 2)

I am happy to revert to composer 1 (maybe it is easier) but when I tried this, the vagrant box and the DO droplet still have composer 2.

I happy to pay if somebody can support me with this, because I run out of possibility. (I am stuck at this point for 2 days, nearly 3 days, the website is ready but I can’t push it live because of this error)

thanks :pray:

Does this error happen on a deploy? Did you try removing your vendor and composer.lock in your theme folder and run composer install In there? Looks like composer/installers is still locked to version 1.6.

yes only on deploy, on local is all ok.

yes I have done that, delete composer.lock and rm -rf vendor && composer install, but no luck.

what else I can try to do?

in the meantime, I am trying with a brand new trellis/bedrock/sage project, but with composer 1 (because I think that I am getting mad with composer 2).

is there a way in trellis to force Composer 1.x to be installed instead of composer 2?

i saw this topic between you and @JordanC26, but it is not clear if at the end this workaround worked or not.

Well the error says that the .lock file is not up to date with changes in the composer.json and that it’s still using composer/installers 1.6? So something is wrong there. What’s in your build-before deploy hook?
Is the path correct to your theme?

yes the path to my theme in build-before is correct, I checked that (it seems correct to me)

maybe a cache issue? (not sure if there is a composer cache or something similar).

Yeah you’ve got:

composer clear-cache

but I doubt that will fix it. Can you try removing:

soberwp/controller

temporary and run composer update again in your theme? Or fix the version to 2.1.2:

"soberwp/controller": "2.1.2"
1 Like

@Twansparant you are my hero <3

I read again your previous msg, I didn’t realise that you suggested deleting that from the theme folder, I did that from the /site/ folder instead. (sorry my fault)

I finally was able to deploy without errors, I can see the staging now, I am so happy that I want to cry :heart_eyes:

I don’t know how many thanks I have to say to you, thanks a lot, you saved me. :hugs:

1 Like

for the future, if somebody will run in the same problem, use this as solution.

and then

did the magic, I will flag as the solution the first one (just because I can’t choose 2 solutions)

big thanks to @Twansparant again :100:

Glad I could help!
Remember, Composer is used in 2 locations with Bedrock & Sage, which both can have conflicts separate from each other.

1 Like