Search code examples
symfonysymfony-2.1composer-php

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"


Solution

  • 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