Patch for module applies with patch command but not composer I have encountered a weird issue in which a patch I rolled for Commerce does not apply with Composer; it gives no errors, but the patch is not actually applied.

  "extra": {
    "patches": {
      "drupal/commerce" : {
        "Allow order types to have no cart": "https://www.drupal.org/files/issues/commerce-direct-checkout-2.2-2810723-37.patch"
      },


However, the same patch applies correctly after downloading and using the patch command:

/web/modules/contrib/commerce$ patch -p1 &lt; ../../../../patches/commerce-direct-checkout-2.2-2810723-37.patch
patching file modules/cart/src/Form/AddToCartForm.php
patching file modules/cart/tests/src/Functional/AddToCartFormTest.php
patching file modules/cart/tests/src/Functional/CartBrowserTestBase.php
patching file modules/product/config/schema/commerce_product.schema.yml
patching file modules/product/src/Plugin/Field/FieldFormatter/AddToCartFormatter.php
patching file modules/product/src/ProductLazyBuilders.php


What is wrong with my patch that makes it fail in Composer?
It turns out this is an issue with Drupal patches for composer when using an older version of Git.  The problem is with composer-patches 1.6.3.

Three possible solutions for now until the bug gets fixed.

Force 1.6.2

In composer.json, specify 1.6.2:

"require": {
"composer/installers": "^1.0.20",
"cweagans/composer-patches": "1.6.2",


Force git clone with 1.6.3

In composer.json, instead of "dist", use "source":

"config": {
    "preferred-install": "source"
  },


Update git to the latest version