Skip to content

Post-scaffold patch fails #183

@jmcintyresage

Description

@jmcintyresage

After I upgraded to version 1.14.0 of the Drupal plugin, a command in post-drupal-scaffold-cmd scripts to patch .htaccess is failing during Composer install/require operations. The operation stops after displaying this message:

Scaffolding files for drupal/core:
  - Copy [web-root]/.htaccess from assets/scaffold/files/htaccess
> patch -p0 < patches/htaccess-customizations.patch
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- web/core/assets/scaffold/files/htaccess	2026-02-27 13:19:40
|+++ web/.htaccess	2026-02-27 13:46:35
--------------------------
File to patch: 

Steps to reproduce:

  • Create a new Drupal 10 Lando project
  • Install Drupal
  • Edit .htaccess and create an appropriate patch
  • Add the command to run the patch via the post-drupal-scaffold-cmd hook to composer.json
  • Install a module via lando composer require

.lando.yml

name: d10tmp
recipe: drupal10
config:
  php: "8.4"
  drush: ^11
  composer_version: 2-latest
  webroot: web

composer.json

{
    "name": "drupal/recommended-project",
    "description": "Project template for Drupal projects with a relocated document root",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/drupal",
    "support": {
        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
        "chat": "https://www.drupal.org/node/314178"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^2.0",
        "drupal/core-composer-scaffold": "^10.6",
        "drupal/core-project-message": "^10.6",
        "drupal/core-recommended": "^10.6",
        "drupal/linkit": "^7.0",
        "drush/drush": "^13.7"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "stable",
    "prefer-stable": true,
    "config": {
        "allow-plugins": {
            "composer/installers": true,
            "drupal/core-composer-scaffold": true,
            "drupal/core-project-message": true,
            "phpstan/extension-installer": true,
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "php-http/discovery": true
        },
        "sort-packages": true
    },
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"
            }
        },
        "installer-paths": {
            "web/core": [
                "type:drupal-core"
            ],
            "web/libraries/{$name}": [
                "type:drupal-library"
            ],
            "web/modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "web/profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "web/themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "drush/Commands/contrib/{$name}": [
                "type:drupal-drush"
            ],
            "web/modules/custom/{$name}": [
                "type:drupal-custom-module"
            ],
            "web/profiles/custom/{$name}": [
                "type:drupal-custom-profile"
            ],
            "web/themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ]
        },
        "drupal-core-project-message": {
            "include-keys": [
                "homepage",
                "support"
            ],
            "post-create-project-cmd-message": [
                "<bg=blue;fg=white>                                                         </>",
                "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
                "<bg=blue;fg=white>  from the drupal/recommended-project template!          </>",
                "<bg=blue;fg=white>                                                         </>",
                "",
                "<bg=yellow;fg=black>Next steps</>:",
                "  * Install the site: https://www.drupal.org/docs/installing-drupal",
                "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                "  * Get support: https://www.drupal.org/support",
                "  * Get involved with the Drupal community:",
                "      https://www.drupal.org/getting-involved",
                "  * Remove the plugin that prints this message:",
                "      composer remove drupal/core-project-message"
            ]
        }
    },
    "scripts": {
        "post-drupal-scaffold-cmd": [
            "patch -p0 < patches/htaccess-customizations.patch"
        ]
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions