composer-patches
composer-patches copied to clipboard
Nested composer dependency patches don't patch in composer update
If you define a composer dependency and within that composer dependency you define a patch for another dependency, when running composer update I'm not seeing that project removed and re-added with a patch applied. Seems like if you update the package itself it willIs this expected behavior? App root composer.json
"require": {
"vendor/my-package": "^1.9",
}
Dependency vendor/my-package composer.json
"patches": {
"drupal/project": {
"My patch": "https://vendor.com/path-to-my-patch.patch"
},
}
Run composer update.
I'd expect that drupal/project would be removed and re-installed to patch.
I think this is a duplicate of https://github.com/cweagans/composer-patches/issues/376 but there's possibly an older issue tracking this too. It's kind of known that generally doing a composer update --lock after the first composer update will then trigger the patched dependency to be re-downloaded.
After more investigation it seems that re-applying patches won't occur for nested composer dependencies that don't explicitly have an update even if the composer.lock file has been updated. It seems that vendor/composer/installed.json may be used to track what may need to be patched. Removing this file before running and update resolves this issue.
Got the same issue. It seems like patches in the part specific to dependency in file vendor/composer/installed.json do not get updated at all. If you delete it or change its content to match your updated patches configuration, yes it works but it's not convenient...
Eventually I end up using vaimo/composer-patches instead which looks more versatile. If you still define your patches in composer.json of your dependency, you will get the same problem. You should use a separate patches.json file that composer.json will refer to (see docs). Every time you update your patches configuration, use the command composer patch:apply that will update installed.json itself :
"target/package": {
"extra": {
"patches_applied": {
"my/package::::patches/my_patch.patch": "A very interesting title, md5:..."
}
},
}
main doesn't resolve patches from dependencies anymore.
main doesn't resolve patches from dependencies anymore.
Can you clarify this comment? Does this mean that, in a future relase, all patches must be defined in the root composer.json file? Can you point to the documentation about the rationale for this change? (I looked and wasn't able to find it.)
main doesn't resolve patches from dependencies anymore.
Yeah this is not expected behavior from a laymans perspective. Can you elaborate if this is intended behavior or just a current gap in the featureset?
I removed it intentionally at the time. Please see https://github.com/cweagans/composer-patches/discussions/478 for further info.