Lando + Composer FTW

<p><span class="drop-cap">I</span> feel I'm having one of those "DUH! Of course!" moments right now.</p> <p>I've been doing updates for years, and cursing every time this happened to me. I have to run a simple command: <code>composer update drupal/core "drupal/core-*" --with-all-dependencies</code></p> <p>We work locally with lando, and use composer within lando as well, so the command would change to: <code>lando composer ...</code></p> <p>So far so good, worked very well.</p> <p>But sometimes, the dreadful message came:</p> <pre> <code class="language-bash">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</code></pre> <p>Wait, what? Why?</p> <p>And it finished with...</p> <pre> <code class="language-bash">Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.</code></pre> <p>But why?! I used it, is it playing with me? Is this script bullying me?</p> <p>Well, no. I realized today, that using Composer within Lando can be confusing for the script sometimes.</p> <p>Somehow, the <code>--with-all-dependencies</code> flag was ignored.</p> <p>The fix is easy. We just need to make sure that the command gets separated, and everything after <code>composer</code> is treated as an argument for Composer, and not Lando.</p> <p>Just add a double dash. Like this:</p> <pre> <code class="language-bash">lando composer update -- drupal/core "drupal/core-*" --with-all-dependencies</code></pre> <p>This is a command line thing. Everything after the double dash <em>is an argument </em>for <code>composer update</code>, and that's it. It worked. It worked so smoothly I felt like I had seen the stars in the meme.</p> <img alt="Mind-blown meme" data-entity-type="file" data-entity-uuid="92bf5421-5e1b-4b1e-8d54-742a54ec9f64" src="/sites/default/files/inline-images/mind-blown-mind.gif" class="align-center" width="314" height="210" loading="lazy" /> <p>Hope this is useful to you as well.</p>

Related blog posts

Adding Compass to a local dev environment with Lando

One of my coworkers asked me to set up a Lando dev environment for him, with the possibility to run Compass commands from within the Lando containers.

Local playground project with Lando for Drupal 8

How to set up a Drupal 8 local development environment to test things out (whatever is on your developing mind) with Lando and Composer.