Waiter, there’s a Baboon in my Drupal! Or how to use Drush in Windows with Babun to manage your Drupal site

I was struggling to find a robust solution to install and run Drupal’s Drush in Windows with MySQL and rsync all playing along nicely.

I run virtual machines to get around this for the larger, more sophisticated sites, but it’s nice to be able to fire up Uniform Server (my preferred wamp stack) now and again and just run things locally. I have tried a  lot of solutions, but the cleanest so far has been to make use of Babun, a rather cool package developed by Tom Bujok and Lukasz Pielak.

Drush command being run on the Babun shell

Babun (pronounced Baboon) is a pre-configured Cygwin with a lot of addons and lot’s of other bells and whistles including a zsh/bash shell and Git. You can download and install the software via:


  1. Download and install babun
  2. Run shell from link or right-click
  3. Install PHP
    • pact find php # this lists all the php packages
    • pact install php
    • pact find php- #shows you what extensions are available
    • pact install php-ctype php-curl php-exif php-fileinfo php-gd php-iconv php-intl php-json php-ldap php-mbstring php-mcrypt php-mysql php-pdo_mysql php-simplexml php-pdo_sqlite php-phar php-session php-sockets php-tokenizer php-xmlreader php-xmlrpc php-xmlwriter php-zip php-zlib # this is currently what I have installed
    • Do not install php-gv as this conflicts with drush
    • Edit the php.ini file in .babun/cygwin/etc/php5/ and find and replace
      ;date.timezone =

      with an appropriate time zone e.g.

      date.timezone = Europe/London
  4. Install MySQL client
      • pact install mysql
      • Create my.cnf  in the .babun/cygwin/etc/ folder and add this:

  1. Other requirements:
    • pact install bsdtar

Update and rebase babun

At this point it’s probably worth running an update and a rebase to make sure everything runs as expected. In the shell run:

babun update

Once that has completed (if anything required updating at all) close the shell(s) you have open and launch the rebase.bat file and let it do it’s thing before restarting the babun zsh shell.

Install Composer & Drush


curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer


composer global require 'drush/drush'

You might notice the single quotes I have put around the package name. This isn’t shown on the drush documentation but is required to prevent an issue with the zsh shell (the babun bash shell will run this without the quotes.) An alternative when using the zsh shell is to use this command:

noglob composer global require drush/drush

Or place this in the .zshrc file:

alias composer="noglob composer"

Update your .bashrc and .zshrc files

Open your .zshrc file in your cygwin home folder (.babun/cygwin/home/*yourusername*/.zshrc) in the shell (vim), or browse in windows and use notepad++ (remember to make sure you force notepad++ to use unix EOLs) and add this to the beginning or end:

export PATH="$HOME/.composer/vendor/bin:$PATH"

Repeat this for the .bashrc file.

Important: Update your Drupal settings

In your Drupal site’s settings.php  add this to the  bottom:

if (file_exists(__DIR__ . '/settings.local.php')) {
include __DIR__ . '/settings.local.php';

Create a new file in the same folder and name it settings.local.php and copy the database connection details for settings.php into this new file. Finally modify the settings.local.php database host from localhost to e.g.

// settings.local.php
$databases = array (
  'default' => 
  array (
    'default' => 
    array (
      'database' => 'mydatabase',
      'username' => 'unhere',
      'password' => 'pwhere',
      'host' => '',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',

You may have to modify this technique if using Drupal 8.


Well done if you got this far 🙂 You should now have an environment to run Drush and all its commands including the powerful sql-sync and rsync commands.

Notes for using your new Babun / Cygwin Windows installation:

  • make sure you run babun update after installing all the new software
  • if you get error warning run the rebase.bat in the babun folder and everything should be fine.
  • take notice of the point on the babun site FAQ about Git – I had to run the suggested config: git config --global core.autocrlf true
  • use the shell which command (which php, which drush) to make sure you are running the expected one and not an old windows installation

6 thoughts on “Waiter, there’s a Baboon in my Drupal! Or how to use Drush in Windows with Babun to manage your Drupal site

  1. Hey, great article. Literally a year of struggling on a windows machine with cygwin, and now it works.

    Yay for babun.

    ps. installed php-tokenizer for drush 8 support

    • Thanks Lowell. Good pointer for Drush 8 support, cheers. I have added php-tokenizer in the instructions.

      I should also say that I updated the underlying cygwin to 2.2.1 shortly after I wrote this article. It’s not officially supported as a technique in the babun documentation, as far as I can tell, but I ran update.bat in the babun root folder from the windows command line to do the update. Everything seems to be working fine for the last couple of months – but make a backup of your original babun folder first in case it all goes pear shaped!

  2. Thanks to you and Babun I got drush successfully running on Windows 7 and Drupal 8, yay!

    I very much appreciate your detailed instructions that even a newbie like myself can follow along!

Leave a Reply

Your email address will not be published. Required fields are marked *