Last updated August 31, 2016.

Here are some steps to use the Windows cmd prompt for patching in Windows. There is a videocast on Installing Cygwin on Windows XP that covers installing Cygwin but not actually using it. For applying patches from command line there is another videocast Applying Patches to Drupal Core. Cygwin must be installed with the patch features. They are not automatically installed.

The following uses the Windows cmd prompt. Cygwin must be installed, but for this to work the Windows cmd prompt must be used instead.

Assumptions

  • cygwin is installed at c:\cygwin
  • the patch is at c:\mypatch.patch
  • The drupal installation is at c:\drupal
  1. Start a cmd window
  2. cd c:\drupal
  3. c:\cygwin\bin\patch.exe -p1 < c:\mypatch.patch

If the patch is successful a line similar to the following will be displayed for each file that was patched.

"patching file core/modules/filter/migration_templates/d6_filter_format.yml"

The following original sentence is unclear. Also, where is the .rej file located?

After the patch is applied check for it saying that hunks failed. If it does it will create a reject(.rej) file where you can look at what has failed.

Comments

okaalto’s picture

When applying Drupal core patches under Cygwin the file permissions of patched files may get broken causing "failed to open stream: Permission denied" errors on require_once() etc. calls, which ends up with WSOD.

When checking the 'ls' output from Cygwin, there's an extra + sign missing in file permissions for the patched files, when compared to other files. This indicates that there are extra permissions (from Windows ACLs) applying, which do not fit to traditional user/group/other categories.

The ACLs can be checked and restored by using commands 'getfacl' and 'setfacl' under Cygwin. Just check what ACLs any other file, which was not patched, has, and then apply the same to the patched files.

marcvangend’s picture

@okaalto: This bug seems to be fixed in the current version.

SweeneyTodd’s picture

I downloaded Cygwin yesterday and tried to use it to apply my first patch today and am getting error messages when trying to open the files.

I am not familiar with unix commands but I managed to work out what @okaalt meant. Here is a bit of help for anyone who is not familiar with getfacl / setfacl.

Tip: I have added the cygwin path (c:/cygwin/bin/) up in the Path of the Environmental Variables in Windows so I don't have to keep typing it in every time I want to use a command (Control Panel > System > Advanced System Settings). This path should be appended to the list and separated by a semi-colon from the previous entry.

The easiest thing is to create a text file containing the permissions from a file that is ok (file1) and then apply those settings to the broken file (file2).

getfacl file1 > acl_file.txt
setfacl -f acl_file.txt file2
noopal’s picture

This link

-> There is a videocast on Installing Cygwin on Windows XP that covers installing Cygwin but not actually using it

leads to an access denied page

findmashmind’s picture

Command c:\cygwin\bin\patch.exe -p0 < c:\mypatch.patch didn't work for me. I changed -p0 to -p1 and then it worked.

joseonate’s picture

A few more notes for anyone having trouble with this:

- donwload Cygwin installer (choose appropriate OS, in my case Win64 version)
- Run installer, don't forget to choose the patch packages. They were not chosen by default (use the search tool to find the patch packages)
- Once installed you should be able to navigate to the working folder, then run patch.exe from the command line. The parameter that works for me is -p1

My command line:
First navigate to working folder with:
cd c:\mymodulefiles

then
C:\cygwin64\bin\patch.exe -p1 < c:\patchlocation\patchname.patch

Worked fine. If it doesn't, you'll get a detailed error message.

Also, I recommend an enhanced CMD tool to make this process easier. Try ColorConsole:
http://www.netbulge.com/colorconsole-a-cmd-alternative/

samstamport’s picture

Please review my edits.