3

I am trying to patch 5 files within an Mac application bundle using the Terminal patch command. The files to be patch are specified using an absolute file path (the file name and path start with a slash).

The output when running $ sudo patch -i ~/custom.patch is:

can't find file to patch at input line 3
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|--- /Applications/Xyz.app/Contents/Resources/dashboard.js
|+++ /Applications/Xyz.app/Contents/Resources/dashboard.js
--------------------------
File to patch: ^C

I have verified that the file /Applications/Xyz.app/Contents/Resources/dashboard.js does exist using at the specified file path using the ls command.

Regression:

  1. Tried to run the patch command from root folder using $ cd /
  2. Tried to run the patch command from root folder with the first slash removed, that results in an almost identical result:

can't find file to patch at input line 3
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|--- Applications/Xyz.app/Contents/Resources/dashboard.js
|+++ Applications/Xyz.app/Contents/Resources/dashboard.js
--------------------------
File to patch: ^C

How can multiple files within a Mac OS X Application bundle be patched using patch?

  • @grgarside The difference is /Applications/ versus Applications/ – Pro Backup Nov 21 '13 at 11:36
3

I think the problem is that you are not specifying the p option.

From the manual for patch:

For example, supposing the file name  in  the  patch file was

  /u/howard/src/blurfl/blurfl.c

setting -p0 gives the entire file name unmodified, -p1 gives

  u/howard/src/blurfl/blurfl.c

without the leading slash, -p4 gives

  blurfl/blurfl.c

and  not  specifying  -p  at  all just gives you

  blurfl.c.

Whatever you end up with is looked for either in the current directory,
or the directory specified by the -d option.

So the command should be something like:

patch -p0 <custom.patch

or you could specify the directory to which the patch should be applied:

patch -d /path/to/dir <custom.patch
  • -p -d look promising when all to be patch files are in the same folder. -p is not an answer, as my wish is to specify absolute path file locations from within the patch file. The wish is to patch different files at different absolute path locations. – Pro Backup Nov 24 '13 at 13:46
  • for -dthat is true. the parameter -p works with the file names found in the patch file. so with the -p0 you should be able to specify absolute file paths – CML Nov 24 '13 at 14:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .