Patching docroot htaccess: file not found 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 &amp;&amp; patch -p1 &lt; ../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:
&quot;post-drupal-scaffold-cmd&quot;: [
     &quot;cd web &amp;&amp; patch -p1 &lt; ../patches/htaccess.patch&quot;
]
Look your patch already has the path to web/ in it:
--- a/web/.htaccess
+++ b/web/.htaccess

Just remove the cd web &amp;&amp;  and adjust the path to the patch accordingly.
&quot;post-drupal-scaffold-cmd&quot;: [
     &quot;patch -p1 &lt; patches/htaccess.patch&quot;
]