To install patches with Composer, I install composer-patches with the command
composer require cweagans/composer-patches
Version 2.0.0 is installed, but it doesn't currently work with Drupal 11.
If I install it like this:
composer require cweagans/composer-patches:^1.7
everything works.
Am I right in thinking that cweagans/composer-patches version 2.0.0 is not yet compatible with Drupal? Is there any official information about this?
---
See #14 for a possible solution.
Comments
Comment #2
vasyok commentedComment #3
cilefen commentedWhat is the evidence that it is incompatible? That information is missing from the issue summary.
Comment #4
cilefen commentedComment #5
vasyok commentedWhat is the evidence?
With composer-patches v 2 patches does not applied.
Comment #6
cilefen commentedDo you have some Composer debug logging? Did you configure the patch tool as documented?
May we see the composer.json file?
Comment #7
cilefen commentedActually, the configuration should be the same between versions. Let’s please see the verbose Composer output
Comment #8
cilefen commentedI did some testing and everything is working on a site that I have with many patches. Follow the composer-patches troubleshooting guide as some things have changed.
Probably Drupal itself is not involved in your difficulties.
Comment #9
vasyok commentedWith cweagans/composer-patches ~2.0, patches defined in extra.patches are silently not applied in a standard drupal/recommended-project setup.
Downgrading to ^1.7.x applies the same patches correctly.
Note: composer patches-doctor is only available in 2.x, so its absence in 1.7.x is expected and not an error.
start composer.json obtained from https://github.com/drupal/recommended-project/tree/11.3.x
not a working solution
with cweagans/composer-patches v 2.0 this file:
Command composer patches-doctor write:
working solution
composer.json same as above but with
Comment #10
cilefen commentedLet’s get all debug information for some support.
Comment #11
cilefen commentedWe need the output of
composer patches-repatch -vvv. It is very unlikely something to do with Drupal but the debug log will help you.Comment #12
mortona2k commentedI also can't apply a core patch.
Output of composer patches-repatch -vvv:
Seems like it's not finding the patches at all. I tried in a separate composer.patches.json file (defined in extra.patches-file). Also tried with patches.json, which is supposed to be the default.
The config did change between 1 and 2.
In 1, it was:
In 2, it's:
Comment #13
mortona2k commentedI had problems with a Drupal CMS instance. It was fixed by deleting the ddev instance, trashing the directory, and starting over.
I fixed my drupal11 instance by deleting patches.lock.json, web/core, and running composer install again.
Some combination of ddev rebuild or composer clear-cache may have helped.
Comment #14
cmlaraCopying messages from Slack that may be useful for others in the future:
Thread: https://drupal.slack.com/archives/C392CHBEW/p1767288647060889
Comment #15
cilefen commented@vasyok May we see the output of
composer install -vvv? I doubt whatever fails is silent in that output.Comment #16
vasyok commentedApplying patches
with composer-patches 1.7.x
In composer.json it is enough to write:
After the patch is written in composer.json, need to run:
composer installwith composer-patches 2.x
In composer.json:
here:
This is sufficient for most of cases.
After the patch is written in composer.json, need to run:
Important note.
Composer-patches 2.x applies patches using git apply and requires patches in git diff format.
This means that patches must include the a/ and b/ prefixes in their file paths:
Patches without prefixes (--no-prefix), for example
cannot be applied with composer-patches 2.x and will result the error:
No available patcher was able to apply patch.An example of how to create a patch correctly.
This doesn't necessarily mean it has to be done this way. It can be done differently.
In the module folder:
Сopy the modified module files over the original ones, then:
Comment #17
quietone commentedThis support request seems to be resolved, it certainly is not a Drupal core issue and there hasn't been discussion for 2 months.
I am closing this per the guidance in Handle or refer a support request in an issue.