I have an old composer based symfony project, that I just updated with some changes of code. I tested in development everything works fine. I have got issue when deploying the composer asked to run composer.phar self-update to update the composer since the composer is outdated. After that I do the composer.phar install. I get this error -
[RuntimeException]
Your composer.lock was created before 2012-09-15, and is not supported anymore. Run "composer update" to generate a new one.
What if I don't want to update. I am okay this. How can I force it not to update.
As mentioned above, the composer.lock file prevents you from automatically getting the latest versions of your dependencies. To update to the latest versions, use the update command. This will fetch the latest matching versions (according to your composer.json file) and update the lock file with the new versions.
composer install is primarily used in the 'deploying phase' to install our application on a production server or on a testing environment, using the same dependencies stored in the composer. lock file created by composer update.
You see, while your composer. json file is a rough guide to the dependency versions that Composer should install, the composer. lock file is an exact record of the dependency versions that have been installed. That's right, it's recording what Composer has installed for you, right down to the commit hash.
To change to version one run the self-update command and pass in the –1 flag. This will change composer to version one and now you can install your dependencies. Once you have installed your dependencies, now you can run the same command and pass in –2 as the flag and this will switch back to composer version 2.
The structure of the lock file was changed, and therefor you should upgrade your lock file. You can upgrade your lock file without actually upgrading any dependencies by executing:
composer update nothing
I would suggest you look at the composer.lock
file and note any versions that are used there. Then copy these into the composer.json
, delete the lock file and run a normal install.
Of course, you do this on a copy of your software to see if all the same versions do appear again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With