I am using symfony 2.1 with composer and I'm trying to run composer update
However, I keep getting "has uncommitted changes", I don't remember changing any of the files in the vendors dir and it comes up with almost every package!
I tried composer install to revert any changes, but it doesn’t seem to have an effect. If I delete the lock file and try an install, I get error messages like "symfony 2.1 requires symfony 2.1 -> symfony 2.1 satisfiable". It just doesn’t make sense.
If I delete the contents in vendors I get the same error messages and nothing installs.
Nothing I do seems to work. Is there a way to update with "force" regardless of "uncommitted changes"
You can use composer status -v
. Here's how you can detect a file change in vendor/
using this command, and how to fix it.
First, we verify that no package is modified:
➜ SymfonyApp git:(master) ✗ composer status
No local changes
Then, we change a vendor file
➜ SymfonyApp git:(master) ✗ echo "modification" >> vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php
We then ask composer to tell us about modified vendor files (note the -v option, to see the modified files)
➜ SymfonyApp git:(master) ✗ composer status -v
You have changes in the following dependencies:
/Users/adrienbrault/Developer/SymfonyApp/vendor/symfony/symfony:
M src/Symfony/Component/HttpKernel/Kernel.php
We then reset the vendor git repository to set the files back to their original state.
➜ SymfonyApp git:(master) ✗ cd /Users/adrienbrault/Developer/SymfonyApp/vendor/symfony/symfony
➜ symfony git checkout .
➜ symfony cd -
~/Developer/SymfonyApp
Finally, we check that the files are not seen as modified anymore by composer.
➜ SymfonyApp git:(master) ✗ composer status -v
No local changes
Update: composer should now help you to handle this
You can also set the discard-changes
to true
in the config parameter of your composer.json file, see https://getcomposer.org/doc/06-config.md#discard-changes.
{
"name": "test",
"description": "Demonstrating concepts",
...
"config": {
"process-timeout": 1800,
"discard-changes" : true
},
...
}
Because this affected various projects sharing dependencies on one server, since for example a vender author would ask me to test quick changes before filing bugs and committing to their repo, I ran this to globally set discard-changes to true:
php composer.phar config -g discard-changes 1
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