How to avoid composer discard changes message
Solution 1
Set composer config to discard changes (see: https://github.com/composer/composer/pull/1188):
php composer.phar config --global discard-changes true
Solution 2
both @lemats and @reza-sanaie's answers are incomplete as --no-interaction (-n) composer's option is required to have a real update without any question (see https://github.com/composer/composer/pull/1188#issuecomment-16011533).
So after
php composer.phar config --global discard-changes true
or after modifying composer.json
"config": {
"discard-changes": true
},
use
php composer.phar update -n
Solution 3
Alternative to @lemats solution you can modify the composer.json file with:
"config": {
"discard-changes": true
},
It's worth nothing for this option to kick in you have to be running in --no-interaction
mode
php composer.json install --no-interaction
Although I agree with @Seldaek on you shouldn't be modifying these vendor files, but sometimes you are forced to monkey patch it :(
smoreno
Updated on June 10, 2020Comments
-
smoreno almost 4 years
I'm updating symfony verdors via composer. I always do it using:
php composer.phar update
But recent version of composer, before update each package show a message like this:
- Updating doctrine/data-fixtures dev-master (a95d783 => a28b6bd) The package has modified files: M .gitignore M .gitmodules M LICENSE M README.md M UPGRADE M composer.json M lib/Doctrine/Common/DataFixtures/AbstractFixture.php M lib/Doctrine/Common/DataFixtures/DependentFixtureInterface.php M lib/Doctrine/Common/DataFixtures/Event/Listener/MongoDBReferenceListener.php M lib/Doctrine/Common/DataFixtures/Event/Listener/ORMReferenceListener.php
-10 more files modified, choose "v" to view the full list Discard changes [y,n,v,s,?]?
How to avoid this?
-
Ascherer about 10 yearsstill happens sometimes. I've seen people with servers that chmod on crontab that mess with the perms of all the vendors. or when debugging a vendor lib, it can happen too
-
Gabriel Alack about 10 yearsYou could always do a pull request to the vendor repo if it is an important fix
-
gidmanma over 9 yearsThis can also happen because of git filemode, especially when the vendor file is something you have symlinked in bin.
-
HappyCoder over 8 yearsAnd bug testing, sometimes you need to var dump in the vendor files to see what on earth is going on... and you may not always put the changes back 'exactly' as they were... maybe a space is added etc.
-
user3399101 over 3 yearssome projects (e.g . Drupal 9.x) modify both checkout files and vendor files, it can't always be avoided.