I tried to create my first patch file in order to reverse the overwriting of the scaffold file .htaccess after executing composer install. I get the following errors:

can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
|diff --git a/web/.htaccess b/web/.htaccess
|index 6f9123d..4ae5471 100644
|--- a/web/.htaccess
|+++ b/web/.htaccess

Script cd web && patch -p1 < ../patches/htaccess.patch handling the post-drupal-scaffold-cmd event returned with error code 1

This is how the patch file looks like:

diff --git a/web/.htaccess b/web/.htaccess
index 6f9123d..4ae5471 100644
--- a/web/.htaccess
+++ b/web/.htaccess
@@ -113,7 +113,7 @@ AddEncoding gzip svgz
   # If your site is running in a VirtualDocumentRoot at http://example.com/,
   # uncomment the following line:
-  # RewriteBase /
+  RewriteBase /
   # Redirect common PHP files to their new locations.
   RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR]

And this is how it is loaded in composer.json:

"post-drupal-scaffold-cmd": [
     "cd web && patch -p1 < ../patches/htaccess.patch"

Look your patch already has the path to web/ in it:

--- a/web/.htaccess
+++ b/web/.htaccess

Just remove the cd web && and adjust the path to the patch accordingly.

"post-drupal-scaffold-cmd": [
     "patch -p1 < patches/htaccess.patch"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.