"The lock file is not up to date with the latest changes" when deploying

This answer was correct but I actually needed to run composer clearcache from the /srv/www/example.com/current directory.

It’s worked on my staging droplet, now to try it on production.