We are trying to apply a patch to a core module using Applying patches after updating Drupal core to 8.5.6. When running patch -p1 < patchname-issuenum-version.patch command, we get the following.

We tried entering /core/modules/some/path/file.php but that did not work. I ran the command from the /core/modules/some/ directory, which is the module's root folder.

How do we resolve the File to Patch issue?

$ patch -p1 < patchname-issuenum-version.patch
(Stripping trailing CRs from patch; use --binary to disable.)
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/core/modules/some/path/file.php b/core/modules/some/path/file.php
|index cb2e5754a..12354789 11111
|--- a/core/modules/some/path/file.php
|+++ b/core/modules/some/path/file.php
File to patch:

1 Answer 1


You need to run patch -p1 < patchname-issuenum-version.patch from the directory containing the core directory, not from core/mdoules/some/ or core/modules/some/. (I take core/mdoules/some/ is a typo in the question body.)

Patches for Drupal core are created from the Drupal root directory, so when you apply a Drupal patch, you need to change directory to that one.

Your Answer

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

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