-1

I am developing a custom module and using composer to require dependencies. In my root composer.json I have:

    "require" : {
        ....
        "drupal/my_module": "^0.2.1"
    },
    "repositories": {
        "drupal/my_module": {
            "type": "path",
            "url": "web/modules/custom/my_module"
        },
        ...
    }

In my module's composer.json, I have:

{
    "name": "drupal/my_module",
    "version": "0.2.3",
    "require": {
        "some/module_a": "^2.6",
        "cweagans/composer-patches": "^1.7"
    },
    ...
    "extra": {
        "enable-patching": true,
        "patches": {
            "some/module_a": {
                "Fix some bug": "https://patch-diff.githubusercontent.com/raw/some/module_a/pull/123.patch"
            }
        }
    }
}

I assume the patch will install when I do composer install on the root level. However, it doesn't happen, and I have to add the patch declaration under the root composer.json to get it to work.

How can I correctly include the patch in the custom module's composer.json?

8
  • 3
    Is web/modules/custom/my_module a git repo?
    – Clive
    Feb 6 at 9:19
  • No, @Clive not yet.
    – John Doe
    Feb 6 at 9:49
  • 1
    I think it’ll need to be a repo, as Composer Patches uses git apply
    – Clive
    Feb 6 at 15:52
  • 1
    That's a good point - do you have "cweagans/composer-patches": true under config.allow-plugins?
    – Clive
    Feb 7 at 1:55
  • 1
    Ohhh, actually I think I worked this one out before once :) See if drupal.stackexchange.com/questions/314142/… applies
    – Clive
    Feb 7 at 1:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.