Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid composer discard changes message

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?

like image 615
smoreno Avatar asked Nov 28 '12 20:11

smoreno


People also ask

How do I fix composer problems?

Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer. json via rm -rf vendor && composer update -v when troubleshooting, excluding any possible interferences with existing vendor installations or composer. lock entries.

What is the use of composer Phar?

It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things. we can think of it as the program's executable. you wouldn't be able to run composer without it. You can place the Composer PHAR anywhere you wish.

Should I composer update?

You should never use composer update without argument. composer update reads every package listed on composer. json, and updates it to the latest available version compatible with the specified version constraints. In a perfect world, all librairies would follow semver correctly, and it shouldn't have any side effects.

How do I update composer Phar?

update / u# In order to get the latest versions of the dependencies and to update the composer. lock file, you should use the update command. This command is also aliased as upgrade as it does the same as upgrade does if you are thinking of apt-get or similar package managers.


2 Answers

Set composer config to discard changes (see: https://github.com/composer/composer/pull/1188):

php composer.phar config --global discard-changes true 
like image 183
lemats Avatar answered Sep 20 '22 02:09

lemats


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 
like image 39
mazenovi Avatar answered Sep 21 '22 02:09

mazenovi