Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer - uncommited changes (symfony 2.1)

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"

like image 570
Stevanicus Avatar asked Sep 13 '12 08:09

Stevanicus


3 Answers

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

like image 152
AdrienBrault Avatar answered Oct 23 '22 08:10

AdrienBrault


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
  },
...
}
like image 24
Goke Obasa Avatar answered Oct 23 '22 06:10

Goke Obasa


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
like image 36
Marcos Avatar answered Oct 23 '22 06:10

Marcos