Composer Lock File Not Syncing

By Paulus, 11 March, 2021

This may or may not be an issue  but it's something that I've run into and took more time than it should have to correct. As far as I know this seems to only be a problem with Lando and may have been fixed by the time you read this.

Out of the blue I started getting the error message when I was trying to deploy an update to a Drupal site. 

The lock file is not up to date with the latest changes in composer.json, it is recommended that you run `composer update` or `composer update <package name>`.

At first I couldn't figure out why this was happening and thought that it had something to do with the build containers and artifacts. The command that the job was failing on was vendor/bin/robo job:build so I tried running it within my local Docker container

Lando ssh -c "./vendor/bin/robo job:build"

No biggie, I can just run composer update like it says and everything should be peachy keen.

lando composer update
# Nope
lando composer install
# Not the preferred way but still didn't work.
lando composer update --lock
# Nope
lando composer update --lock --no-cache
# Still no
rm composer.lock
# Now it's just gone and the following won't bring it back.
lando composer update --lock --no-cache
lando composer update --lock
lando composer install
rm -rf vendor
# Now we're getting desperate
lando composer update
# Yay! composer.json and composer.lock are sync'd.

That only fixes the problem until you need to make updates to the composer.lock file. What I ended up doing is running composer natively to update the lock file.


lando composer require drupal/pathauto
composer update --lock-file --ignore-platform-reqs

As I said previously, this may simply be an issue with my work Mac since there is no problem on my Gentoo desktop. At the very least this was a learning experience.