Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When doing composer update, composer complains that files are edited?

When I run

php composer.phar update

composer complains that all of my libs are modified - even though I didn't touch them.

  • Updating jdorn/sql-formatter (dev-master 3d8a973 => v1.2.9) The package has modified files: M lib/SqlFormatter.php

Note: I pulled the project from a remote repository.

Could it be that encoding messed up in the process?

How to fix this?

like image 998
Tool Avatar asked Feb 17 '23 07:02

Tool


2 Answers

"even though I didn't touch them."

Well something did. If you think it wasn't you then it could be your IDE 'helpfully' reformatted it to your specified standards.

What you ought to do is:

  • Go into the directory vendors/jdorn/sql-formatter

  • Run the command git diff

That will show you what has actually changed. If it's just whitespace/code reformatting then it probably is your IDE that has 'helpfully' changed the files.

If it's an actual code change then it was probably yourself just not realising which file you were in.

If it's something else, then there could be another cause, but the git diff should allow you to figure out what it is.

like image 173
Danack Avatar answered Apr 29 '23 19:04

Danack


The following answer seems to be the most complete one that I could find, it solved the problem (though not the source of the problem):

https://stackoverflow.com/a/24606663/667773

Quoted from the answer of @mazenovi:

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 20
Denes Papp Avatar answered Apr 29 '23 19:04

Denes Papp