$ less ~/blog/lando-composer-ftw.txt
-rw-r--r-- ana Apr 12 2022 lando-composer-ftw.txt
ARCHIVED · written in 2022. Kept as it was; some of it may be out of date.
Lando + Composer FTW
I feel I’m having one of those “DUH! Of course!” moments right now.
I’ve been doing updates for years, and cursing every time this happened to me. I have to run a simple command: composer update drupal/core "drupal/core-*" --with-all-dependencies
We work locally with lando, and use composer within lando as well, so the command would change to: lando composer ...
So far so good, worked very well.
But sometimes, the dreadful message came:
Your requirements could not be resolved to an installable set of packages.
Problem I
Some package is locked and an update was not requested
Some package requires another package, but it conflicts with another require
Wait, what? Why?
And it finished with…
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
But why?! I used it, is it playing with me? Is this script bullying me?
Well, no. I realized today, that using Composer within Lando can be confusing for the script sometimes.
Somehow, the --with-all-dependencies flag was ignored.
The fix is easy. We just need to make sure that the command gets separated, and everything after composer is treated as an argument for Composer, and not Lando.
Just add a double dash. Like this:
lando composer update -- drupal/core "drupal/core-*" --with-all-dependencies
This is a command line thing. Everything after the double dash is an argument for composer update, and that’s it. It worked. It worked so smoothly I felt like I had seen the stars in the meme.
Hope this is useful to you as well.