Composer revert packages
Asked Answered
S

6

27

I am building a new app in Symfony 2.1. I am using a lot of bundles pulled in using composer. A lot of these bundles have problems with this latest version of Symfony and I am having to go into the /vendor folder to identify the issues.

This means that I am changing the vendor files directly - purely for testing purposes. (When we have fixed a bundle we branch and submit appropriate pull request).

What I want to know is if there is some command like composer.phar revert which would undo any changes made to the vendor folder (like a git checkout). At the moment if I run a composer update or installit does not do this.

Thanks

Spoonfeed answered 6/6, 2012 at 14:23 Comment(2)
+1 for the interesting question, but you mean git checkout, don't you?Desmid
Yes I do! Sorry, too long using SVN...Spoonfeed
V
24

composer install, if you have kept your composer.lock file, will revert all your vendors to the previously installed state.

Variolite answered 11/6, 2012 at 9:16 Comment(4)
This doesnt work for me I get the error "directory ... has uncommitted changes" which causes it to abortSpoonfeed
Oh right, this will be addressed by github.com/composer/composer/issues/466Variolite
You saved my day !Minimal
@Variolite This no longer works, but I can see that some files where changed with composer status -v. I had to manually remove the package and then run composer install.Amherst
P
21

If you used composer update your composer.lock has changed to. So I make a little trick. Revert composer.lock by git and then run composer install. It'll remove newest packages and download the previous.

Penance answered 6/5, 2015 at 15:1 Comment(0)
B
4

Add discard-changes to your composer.json file:

{
    "config": {
        "discard-changes": true
    }
}

Make sure you are using the latest version of Composer.

Bifocals answered 9/3, 2016 at 5:52 Comment(0)
C
2
 cd /my/project/location/

 rm -rf vendor/my_vendor_to_rollBack

 composer install
Comity answered 4/1, 2017 at 17:21 Comment(1)
works, but there should be a better method for achieving this.Rude
A
0

As far as I can tell, none of the answers above work except in relation to versions. I you change an installed version, you can revert to a previous version.

If you just delete or change a file, though, the change will show up in composer status -v, but there's no way to revert (even with "discard-changes":true) except by removing and then re-requiring the package.

Athematic answered 22/5, 2019 at 21:32 Comment(0)
W
0

composer reinstall "*" removes and installs again all packages in vendor directory.

Wardwarde answered 31/7, 2022 at 8:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.