Last updated 2 July 2013. Created on 8 February 2012.
Edited by Jean Gionet, rj, johntelford, OpenChimp. Log in to edit this page.

This is an alternative way to get Drush running on a Windows 7 system using the Cygwin environment. There is existing documentation on installing and running Drush using GnuWin tools and the native Windows shell at: http://drupal.org/node/594744

If you would like develop Drupal projects on Windows 7 using installation profiles, Drush Make and Git, the Cygwin environment provides a powerful toolset which matches configurations that you would might find on Linux or OS X . More information about using Drush Make to develop installation profiles can be found at: http://drupal.org/node/1006620

Requirements

Before you start installing the Cygwin environment you will need to make sure you have an existing installation of PHP on your Windows system which can be called from the command line of a shell program. Installing PHP on Windows 7 is outside the scope of this article but we'll assume you have already installed XAMPP or something. A default installation of XAMPP will mean that a PHP executable is installed at the path C:\xampp\php\php.exe. This article also assumes that you do not have Windows User Account Control active. There are many articles around the web which explain how to disable it, search for "Disable Windows 7 User Account Control".

To check that PHP is available from your PATH environment variable open the program Command Prompt. Command Prompt is the default shell program for Windows 7, you will find it in your Start menu or you can search for cmd.exe. Test that PHP available by running the command:

php -v

The output should look something like this:

PHP 5.3.8 (cli) (built: Aug 23 2011 11:50:20)
...

If you get an error that starts with "php is not recognized..." you might need to add the folder containing your PHP executable to the PATH variable. To edit the PATH go to Control Panel > System and Security > System > Advance System Settings > Advanced tab > click the Environment Variables button. In the lower section of the Environment Variables window under System variables select Path, then click Edit.

Assuming that C:\xampp\php\php.exe exists you need to add the following folder to PATH, making sure you separate your new entry with a semicolon.
;C:\xampp\php

Now re-open Command Prompt (you will need to close it first to reload the updated PATH variable) and try typing "php -v". You should see the friendly version number output from PHP. If you still get errors you will need to double check your PHP installation.

Installing Cygwin

Grab the Cygwin Setup program from the homepage of the Cygwin site at: http://www.cygwin.com/

When you run the Cygwin setup.exe program it will select a number of packages to install by default, when you arrive at the Select Packages screen of the setup program you need to install the following additional packages:

  • openssh
  • git
  • rxvt
  • patch
  • patchutils
  • unzip
  • nano
  • vim
  • wget
  • connect-proxy
  • curl
  • rsync
  • bsdtar
  • ncurses
  • mysql

Cygwin Setup will install some additional dependencies and then generate a number of Desktop Shortcuts and Start menu items for the various Cygwin shell programs which have been installed. After you've exited the Cygwin installer you can always install more packages by running the Cygwin setup.exe program again. You won't overwrite your existing installation, you will just be able to add further packages.

Installing Drush using Cygwin

Now that we've got all the required tools we can move onto installing Drush in the Cygwin environment. We will be installing the latest All-versions-5.x-dev version of Drush because it has better support for Windows 7 and also has Drush Make built-in.

To access the Cygwin environment open the Cygwin shell program called rxvt-native. We are going to install Drush in Cygwin at the path /usr/local/src/. In the following step we will download Drush and extract the files from the project archive (at the time of writing the latest version of Drush 5 was a development release, use the latest recommended release of Drush 5 if there has been an update in the meantime). You can find the download link we use below from the Drush project page: http://drupal.org/project/drush

From the command line, type each line in the following text as a separate command:

mkdir -p /usr/local/src
cd /usr/local/src
wget http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz 
tar -zxf drush-7.x-5.9.tar.gz

Now we should have all the Drush project files at the path /usr/local/src/drush so that the main Drush script is located at /usr/local/src/drush/drush. To complete the installation we need to make some files executable and create a symbolic link so that we can run Drush from anywhere inside Cygwin.

chmod u+x /usr/local/src/drush/drush
chmod u+x /usr/local/src/drush/drush.bat
ln -s /usr/local/src/drush/drush.bat /usr/bin/drush

That completes the installation and setup of Drush in the Cygwin environment, test it out by running drush from the command line:

drush

You should get an output of all the drush commands available.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

Anonymous’s picture

I installed cygwin, work very well, Drush is also ok but doesn't recognise when in a valid drupal root folder
I used a symbolic link to my xampp htdocs (on windows) and here what i get:
PHP configuration : C:\xampp\php\php.ini
Drush version : 6.0-dev
Drush configuration :
Drush alias files : C:\cygwin\usr\local\src\drush\includes/../aliases.dru
shrc.php /drush/aliases.drushrc.php
I get the same result when I copy the folder under /home/my-name/home/www/drupal (equivalent to c:\cygwin\home\my-name\home\www\drupal ) to avoid the question of the symbolic link

I manage to run a makefile in a new folder but if drupal got installed, I don't understand what's happening when launching a drush dl features for example. I get a success message but nothing happens in the folder

steveOR’s picture

Thanks for posting this. Everything worked as described with drush 5.8 on a windows 7 machine. After installation I can easily open cygwin prompt, navigate to my xampp site root, and drush to my heart's desire. Yes!
Steve Or Steven

jhoffmcd’s picture

I've been able to successfully do this on 3 Windows machines now. Thank's for making the Drupal experience easier for us! (We have no choice over server environments...)

rj’s picture

If you're using cygwin + git and authenticating with ssh keys, you may get an error about a ca-crt key not being properly configured. Install the ca-certificates package to fix this.

Also, in git you will want to set core.autocrlf to FALSE. This fixes a problem where you do a git pull but then a git status shows that all the files you just pulled have been modified.
git config --global core.autocrlf false

--rj

prabhatjn’s picture

Thank you for this guide. My cygwin with drush is now working on windows 8. I think mysql component may not be needed as it comes already with XAMPP, so just like php one only need to add the path variable to mysql bin folder.

Prabhat.

jomesili’s picture

John@John-PC ~
$ drush
Unable to untar C:\cygwin\usr\local\src\drush\lib\druB6B3.tmp. [error]

Well i was able to solve this from this post here http://stackoverflow.com/questions/18129596/drush-on-cygwin-setup

Run the installation of Cygwin again,
When you get to the point of installing the packages,
Type bsdtar in the search text box at the top left side,
Ensure you open the tree structure and ensure that it is enabled for download
Complete your installation and retry running you Drush commands

Happy Cygwing or Drushing

eric.chenchao’s picture

I have installed setup-x86_64.exe on Win 8.

If you cannot search rxvt, search and install mitty instead.

mmzimu’s picture

Recent Cygwin versions support PHP (and PEAR), so now you can install drush the easy way:

1. Install PHP and PHP-PEAR packages using Cygwin Setup,
2. Execute the following from command line:

pear channel-discover pear.drush.org
pear install drush/drush
pinueve’s picture

I followed instructions to the letter and I get this error on windows 7 64bits.

PHP Warning: require(/usr/local/src/includes/bootstrap.inc): failed to open stream: No such file or directory in /usr/local/src/C:\ProgramData\Drush\drush.php on line 11
PHP Fatal error: require(): Failed opening required '/usr/local/src/includes/bootstrap.inc' (include_path='.:/usr/share/pear') in /usr/local/src/C:\ProgramData\Drush\drush.php on line 11

please help

n0rtan’s picture

you can edit /usr/local/src/drush.php and set an absolute path to includes...

change: require(dirname(__FILE__) . '/includes/bootstrap.inc');
to: require('/cygdrive/c/cygwin64/usr/local/src/drush/includes/bootstrap.inc');

where "/cygdrive/c/cygwin64" is path of your cygwin

gratiafide’s picture

I had to run the symlink command like this to get it to work. I don't know why and I would be interested to hear an explanation if someone knows why I had to do it like this instead of the way the article directs:

ln -s /usr/local/src/drush/drush.bat /usr/bin/drush.bat

The only difference is adding the .bat prefix to the 2nd filename path.

malavya’s picture

In my Windows machine I have installed Drush using Cygwin & PEAR. Though it runs fine when I run drush; shows me all the available commands but when I run any drush command inside a Drupal folder its throws me an error saying:

require_once(d:/wamp/www/d7/modules/system/system.module): failed to open stream: No such file or directory drupal.inc:21                                                          [warning]
PHP Fatal error:  require_once(): Failed opening required 'd:/wamp/www/d7/modules/system/system.module' (include_path='.:/usr/share/pear') in /usr/share/pear/drush/includes/drupal.inc on line 21
require_once(d:/wamp/www/d7/modules/system/system.module): failed to open stream: No such file or directory drupal.inc:21                                                          [warning]
PHP Fatal error:  require_once(): Failed opening required 'd:/wamp/www/d7/modules/system/system.module' (include_path='.:/usr/share/pear') in /usr/share/pear/drush/includes/drupal.inc on line 21
gallaghc’s picture

I have had this same issue. A workaround I found was to run drush from the drush includes directory and use the -r switch to point to your drupal directory. I realize this is not ideal, but I can't seem to get the paths set up correctly to read from the includes directory of the drush install.

kevngibsn’s picture

Due to the errors with loading the Bootstrap include mentioned in other comments I gave up on this method and installed via Composer instead.

laxman2021’s picture

Hi Everyone.

I have a problem installing drush in Cygwin.

- Cygwin

- Windows10

- wamp

$ php -v
PHP 7.0.19 (cli) (built: May 14 2017 03:05:05) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.19, Copyright (c) 1999-2017, by Zend Technologies

- Error :

$ drush
PHP Fatal error: Uncaught Error: Call to undefined function ctype_alnum() in /cygdrive/c/cygwin64/usr/local/src/drush/includes/command.inc:877
Stack trace:

-- Can anyone please help me with this.

Your help is greatly appreciated.