A Guide to Patching Drupal Modules in Windows

To sustain this free service, we receive affiliate commissions via some of our links. This doesn’t affect rankings. Our review process.

So you’ve got everything working except for one nagging little bug that’s keeping your site from rocking the world. This is normally where patches come in. There are two kinds of patches – those that eventually get rolled into the production version of a module, and those that are temporary hacks to fix a longer term issue. I would recommend only using those you feel will eventually be rolled into the code, and if possible, avoid patches entirely for compatibility reasons. Too often a patch will fix a temporary issue that will later be solved in a different way and render your “patched” database structure obsolete. That being said, here’s how to patch a Drupal module in Windows:

Download Cygwin

Cygwin is a Linux-like environment that runs in Windows. The dll (cygwin1.dll) acts as a Linux API emulation layer giving you basic Linux API functionality. The complete download comes with a collection of tools that provide a Linux command prompt look and feel. As a first step, you’ll need to download and install the latest version of Cygwin.

You can install the default packages, but make sure you include the “patchutils” package under the “Devel” section.

Common Cygwin Commands:

Here’s a list of the commands you’ll need to access the patch directory:

  • ls -al — lists the contents of your current directory
  • cd .. — moves you up to the parent directory (note the space between cd and .. if you come from a DOS background!)
  • cd foldername — moves you to a specific folder visible from your current directory

Steps to Patch a Drupal Module in Cygwin

Here are the basic steps you’ll need to follow to patch your module:

  • Copy the patch file and original module to the same directory, one you can access via the Cygwin commands above.
  • Run this command: patch filetobepatched < patchfile or patch -p0 < patchfile

Voila 🙂 Post any questions or comments below.

Windows Vista

If you’re using Windows Visa, run Cygwin as an administrator. You’ll also need to uncheck the “read only” flag on files you modify, and adjust permissions (under the security tab) to allow full access for your user. Otherwise, you’ll have trouble copying and uploading files – you’ll get “permission denied” errors.

Disclaimer: This website contains reviews, opinions and information regarding products and services manufactured or provided by third parties. We are not responsible in any way for such products and services, and nothing contained here should be construed as a guarantee of the functionality, utility, safety or reliability of any product or services reviewed or discussed. Please follow the directions provided by the manufacturer or service provider when using any product or service reviewed or discussed on this website.

Alex bring a series of in-depth articles on search marketing and content management systems as well as troubleshooting tips to We Rock Your Web's collection. He is an avid tennis player, nature enthusiast, and hiker, and enjoys spending time with his wife, friends, and dogs, Bella and Lily.

7
Leave a Reply

avatar
newest oldest most voted
Anonymous
Thank you for the link to cygwin. One question, though, how are file permissions set using Cygwin?

Thank you.

Anonymous
Excellent resource for us Windows users – thank you! I’ve been having to wait for patches to be rolled in to official releases. Not anymore – now I can apply updates right away. Thanks!!
Anonymous
Thanks for the Cygwin/ Drupal tutorial. I’ve got this installed on Windows Vista, with UAC turned on, and I was able to patch a file successfully. However, I can’t copy it over to my Drupal directory, even if I use the bash “cp” command from within the bash shell. Any ideas?
We Rock Your Web
Great question – run Cygwin as administrator and then update permissions on your patch file to allow full access to your user, and uncheck the “read only” box. I’ve updated our article to reflect this new information.
Anonymous
Hi, it didn’t work for me and gave me a hideous error saying “3 out of 4 hunks failed, saving rejects to file”. Any clue about it?

We Rock Your Web
Drupal patches are very version-specific. Make sure you’re applying the patch to the module that matches the version # of the patch. If you’re still seeing errors, try the patched module anyways – sometimes errors are thrown and the module still works.

Anonymous
Thanks for the step by step. It really helps me a lot.