composer-patches: Re-running Composer Update fails because of Modified Files from previous patch
After patching a module, unless you remove the directory where the patched module is located, when you re-run Composer Update you will get a message about “the package has modified files” which you have to discard or the module will fail to download and be re-patched. Below is an example:
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
- Updating drupal/ajax_comments dev-8.x-1.x (44b6bf2 => 44b6bf2)
The package has modified files:
M ajax_comments.module
M src/Utility.php
Discard changes [y,n,v,d,s,?]? n
Update failed (Update aborted)
Would you like to try reinstalling the package instead [yes]? yes
- Removing drupal/ajax_comments (dev-8.x-1.x)
The package has modified files:
M ajax_comments.module
M src/Utility.php
Discard changes [y,n,v,d,?]? y
- Installing drupal/ajax_comments (dev-8.x-1.x 44b6bf2)
Cloning 44b6bf2
- Applying patches for drupal/ajax_comments
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (3 by maintainers)
I can confirm that adding
"config": { "discard-changes": true },to the composer.json and then calling
composer update -n(i.e. with the --no-interaction option), then you get rid of all your conflicts.BTW, those conflicts happen if composer clones a package from source in case there is no distribution available. That leads to a git working copy with change tracking where you won’t get that for most of your packages if they have distros.
"discard-changes": truewith-nworks for me.