How can I patch a Composer dependency to make the dependency compatible with other dependency versions?

mw flag

I'm trying to update my site from D9 to D10, I've had quite a lot of modules to go through, and for the most part a lot of them have releases which are stable for D10, but roughly 4-5 of them only have the auto-generated patch (which I've referenced in the composer.json file)

Except for some reason composer doesn't seem to acknowledge the local patched version when I'm trying to update Drupal Core

if I run composer update -W I get errors like this

- drupal/pdf[1.1.0, ..., 1.x-dev] require drupal/core ^8 || ^9 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev, 9.0.0-alpha1, ..., 9.5.x-dev] but it conflicts with your root composer.json require (^10).

So then I ran composer show drupal/pdf to get

name     : drupal/pdf
descrip. : Display PDF file in Drupal without external readers and plugins.
keywords : 
versions : * 1.1.0
type     : drupal-module
license  : GNU General Public License v2.0 or later (GPL-2.0-or-later) (OSI approved)
homepage :
source   : [git] 8.x-1.1
dist     : [zip] 8.x-1.1
path     : /var/www/html/docroot/modules/contrib/pdf
names    : drupal/pdf

source :

drupal/core ^8 || ^9

Obviously I can see the bottom line appears to be what it's failing from, but I have already installed the patch locally via composer which fixes this, and I can even see that my locally installed file says

core_version_requirement: ^9.3 || ^10

Is there anything I have to do other than reference the patch file for the D10 upgrade for these custom modules?

de flag

composer update is run before patches are applied, which is why your patch is not working, as it is not seeing the patched version yet, and therefore finds incompatibilities.

See this link for information on how to deal with this issue:

Andrew Morris avatar
mw flag
Perfect, that's great, thank you!

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.