How to Patch a Drupal Module on Windows

posted Oct 13, 2011, 7:13 AM by magic stone

If you use Drupal on a regular basis, chances are that you will want to apply a patch to a module at some point in time. Perhaps somebody has posted a patch in the issue cue that sounds like it will address a problem you are having. Patching files on windows is simple. Just follow these steps.

1. You will need to download the patch software. You can download the Patch program at

2. Run the setup file and install the program using all of the default settings.

3. Get a local copy of the file you wish to patch. Either pull down the file from your web server using an FTP client, or just download the module form the drupal project page.

4. Open up a windows command prompt by going to Start->Run and typing "cmd" and hitting enter.

5. Change directories to the GNU Patch program directory using the command prompt by typing the command "cd C:\Program Files\GnuWin32\bin" (no quotes)

6. Place the file that needs patching inside this same folder. For example, if you wish to patch the file views.module, place this file inside the folder at C:/Program Files/GnuWin32/bin

7. Using the command prompt, type the command "patch < NameOfThePatchFileYouDownloaded --binary" (no quotes). For example, if the patch file you have downloaded is named "edit_form.patch" you would give the command "patch < edit_form.patch --binary" but without the quotes. The --binary can be very important on a windows machine. On MS-Windows, the patchfile must be a text file, i.e. CR-LF must be used as line endings. A file with LF may give the error: "Assertion failed, hunk, file patch.c, line 343," unless the option '--binary' is given.

8. Once the file is patched you may upload it for testing.