Common problems
UNIX vs. Windows end-of-line encoding
Text files originating from UNIX systems use a single linefeed character (LF) to mark the end of a line, whereas Windows systems use a carriage return followed by a linefeed (CRLF).
The GnuWin32 patch program may crash on a patchfile with Unix end-of-line encoding throwing the error "Assertion failed: hunk, file [path]/patch.c, line 339".
Most patches downloaded from drupal.org are UNIX text files. When you use patch on Windows, you need to convert line-endings using a unix2dos utility or a decent text-editor.
One way to do this is to open the file with WORDPAD, choose "Save as" and select as type Text document.
Patch can't find the target file
This usually means that you are either executing patch in the wrong directory or that the patch was made relative to another directory. Open the patchfile and locate the lines describing the changed files to determine the path:
--- modules/codefilter/codefilter.module Tue Mar 28 15:04:48 2006
+++ modules/codefilter/codefilter.module Sun Apr 23 15:51:32 2006The above patch appears to be made relative to the drupal root directory so you can execute the following command from the Drupal root:
patch -p0 < file.patchThe number after -p determines the number of path elements that should be ignored. This is very useful when you need to apply a patch that was made against an old and new directory:
--- olddir/modules/codefilter/codefilter.module Tue Mar 28 15:04:48 2006
+++ newdir/modules/codefilter/codefilter.module Sun Apr 23 15:51:32 2006You can apply this patch from the Drupal root by stripping the first path element; 'olddir' / 'newdir':
patch -p1 < file.patch
As a fast solution you can
As a fast solution you can use following command for applying the patch (end line safe)
patch {file} {patch} --verbose --binaryNote that by using --binary patch.exe will no longer affected by line ending characters issue
sina.salek.ws
Feel freedom with open source softwares
Patch files sometime patch multiple files
If you get a "Patch can't find the target file", but the first hunk seems to have worked, then your patch file might require a second file. The patch will give you a little prompt like "file to patch>".
Look at the output just above the prompt and enter the location of the file that caused patch to choke.