Cygwin Quickstart for Drupal Users

Cygwin is a great set of Unix/Linux utilities for Windows. Here are quickstart instructions for using it in a Drupal context (for git, patch, ssh, or whatever)

  • Grab the small setup.exe from http://cygwin.com
  • Run it. If you're on Windows Vista or later, you'll want to run the setup with administrative privileges (Right click on setup.exe and "Run as administrator")
  • Take all the defaults - we'll end up with an install in c:\cygwin
  • When you get to the package selection screen, select at least: openssh, git, rxvt, patch, patchutils, telnet, unzip, nano, vim, rsync, wget, connect-proxy. Then let it download and install.
  • Run "Rxvt Native" from the start menu. (If on Vista or later, you need to run it as administrator this time because we'll be setting up links in a privileged directory). The first time you do this it will install default profile files for you.
  • In rxvt we'll now set up symbolic links to the Windows filesystem. Do this for each drive you have... I'm showing the C: and D: drives here:
    cd /
    ln -s /cygdrive/c
    ln -s /cygdrive/d
  • Now you can navigate into the Windows filesystem to wherever your Drupal install is. /c is the root of the C: drive; /d is the root of the D: drive. For example, if you have Acquia's DAMP installed, it might be in /c/Users/rfay/Documents/Sites/acquia-drupal or something like that.
  • Using cvs, you could check out the Examples project, for example:
    export CVSROOT=:pserver:anonymous@cvs.drupal.org:/cvs/drupal-contrib
    cvs login (your password is 'anonymous')
    cvs -z6 checkout -d examples-HEAD contributions/modules/examples

    and now you have a HEAD version of Examples.

  • Using git you could get Examples from git.drupalfr.org:
    git clone git://git.drupalfr.org/git/contributions-new-date/examples.git
  • Or apply a patch using patch.... or create a patch using git diff --no-prefix...

The world is your oyster. You have the easy-to-use editor nano if you want to edit within Cygwin, but you can just use the Windows editor of your choice as well.

You may also want to watch the Lullabot video on installing Cygwin, which is old, but still useful and valid.

Edit: You can now use drush successfully on Windows! See Installing Drush on Windows Using Cygwin.

15 Comments

Cygwin + Drush

One other great use I can imagine for Cygwin is Drush. There appear to be a couple of issues to get Drush (and Drush 3 specifically) running with Cygwin though. I think a lot of people would appreciate a follow-up article on Cygwun + Drush. It looks like it hasn't been done before.

Drush + Windows

Drush + Windows has definitely been done, but there are a few issues. I just committed a Windows-related fix to drush-HEAD; we could definitely use some good Windows hands in the drush queue to suggest and test patches.

Thanks for the great cygwin article.

Mintty

I personally recommend to grab in the package selection "mintty". It's an alternative interface over Cygwin that makes everything nicer visually and more natural behaviors for Windows-users like selection of text, Right Click -> Copy, windows resizable, Drag&drop etc

Also can be grabbed as a standalone program http://code.google.com/p/mintty/

Also, unlike rxvt it supports

Also, unlike rxvt it supports Unicode (i.e. UTF-8), which is the default in latest Cygwin.

Still now?

I am interested to know -- are you still using andLinux, mikeytown2, or have you moved to a more promising system?

Typing by hand?!

Are you serious ;) To get an Explorer context menu entry for directories instead, you

<

ul>

  • also grab chere and mintty packages
  • run the following command and be done:
    chere -i -t mintty -e "&Bash Here"
    The -e option allows you to change the text to be shown in the context menu to your likings.
  • I wish the windows keyboard

    I wish the windows keyboard shortcuts stuff was more reliable. It works......occasionally.

    I hate having to grab the mouse and click on an icon to simply open up a gd shell.

    What's the key here??

    had to also specify the --binary option with patch

    Randy, I found your article looking for a solution to errors I was getting trying to apply a patch using Cygwin:

    Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

    Using the --binary option solved this for me.
    as in:
    $ patch -p0 --binary < /cygdrive/f/depot/patches/filedepot-use_url_for_links.patch

    Cygwin with Linux line endings?

    I suspect you may have installed cygwin not taking the default line ending setup (which is to use Unix/Linux line endings) and instead using Windows line endings. I haven't had this problem patching in cygwin myself. But since Cygwin is really a Linux environment, it's important to use the Unix/Linux-style line endings when doing cygwin.

    Symbolic links incompatible with drush

    The symbolic linking mentioned in the article (e.g. ln -s /cygdrive/c) has a problem with drush. I've installed drush 5 with WAMP today easily thanks to http://drupal.org/node/594744 but simple downloads such as drush dl devel were being installed in a Windows folder of the same name as the symbolic link.

    E.g. on site "/c/www" (folder "www" on C drive) the above drush command created a folder "c" on C drive.

    Solution: avoid the symbolic links and simply run drush on the default cygwin path, e.g. "/cygwin/c/www".

    Added to the article

    Thanks so much. I added the link to the article. Thanks for pioneering and documenting this great work.