getting drush 3 to work with cygwin
Being one to avoid religious arguments, I tend to not get too upset by some of the hoops Windows can put me through - but I will admit that Unix-based development usually has fewer mysteries to it. I've got a Mac and a Linux server, so why do I put up with Windows at all? Short answer is that as a professional Drupal developer, I can't imagine life without the phpED IDE. Simple as that. I hadn't used an IDE for years, but fell in love with phpED after Peter Lindstrom walked me through it a few Drupalcons ago. I've tried Eclipse and some other debuggers, but nothing comes close for productivity for me.
But there's still that Windows part, and as masochistic as I am at some times, there's now way I'm going to working the cmd window. Fortunately, we have cygwin, a pretty decent Unix shell that runs under Windows and allows me to use Unix commands and familiar tools. I use it in conjunction with the LAMP stack Xampp to have a pretty nice local dev environment. However, it has one foot in each world, and took me a little work to figure out how to get drush to work with it.
Actually, I'd been using drush for some time on my local, and only started having problems when version 3 was released. One of the new features it introduced is site aliases, which allow you to set up a list of shortcuts to the configuration for a particular local or remote site. Before that, I'd been using a mishmash of batch scripts to run the right config for the different sites I work on, or had to create drushrc files for each site and reference them on the command line.
I read Morten's excellent tutorial on drush configuration for the Mac and had it running there is a few minutes. But I just couldn't get it to work under cygwin on my PC.
In my .bashrc, I added this alias to point to drush:
alias drush="/cygdrive/p/drush/drush"
I also made a symlink from my Xampp php executible to /usr/local/bin/php. Drush worked fine as long as I had a drushrc.php file for a site, or use -r and -l args on the command line to point to my site.
So far so good. But when I tried "drush sa" to list my site aliases, I would get strange errors. Greg Anderson suggested I try setting a global site-alias option in my master drushrc.php file (the one in my drush directory), to point to my ~/.drush directory, where I have my aliases.drushrc.php file. So I tried
$options['alias-path'] = '/home/phil/.drush';
but that didn't work. After a lot of experimenting, it turns out this is the answer:
$options['alias-path'] = 'c:\\cygwin\\home\\phil\\.drush';
It wanted a Windows-style path, even though the Unix-style paths work fine in places like settings.php. The drushrc appears to being evaluated in Windowsland, but things get more Unixy once we are in Drupal. Dangit, why does life have to be so difficult sometimes?
One more thing - when I run this on my PC, I see the line #!/usr/bin/env php whenever I run drush. Taking a clue from Solomon, I edited drush.php and removed it. Works fine without it, and no annoying extra output.
I'm delighted now, and love the extra power of site aliases (which even have powers of inheritence). If you haven't used them yet, by all means give them a try. Here's a brief introduction article.
A bit of head scratching, but a big payoff, and I know a few more Windows/cygwin gotchas. Funny how a geek can invest hours in something that can save a few minutes. But when you're deep in the middle of coding, a few seconds delay can make you lose an entire train of though sometimes, so I don't regret it. Or as my hero Larry Wall put it, "The three chief virtues of a programmer are: Laziness, Impatience and Hubris."
tweetme: pglatzbloggity
-
4 Sep 2010
-
14 Aug 2010
-
12 Aug 2010
-
11 Aug 2010
-
11 Aug 2010
Curated Image
Tweeted
- NYT vs WSJ, Taiwanese style http://tinyurl.com/2vvfuan (Pinch inherited his father's position but not his savvy) — 5 hours 26 min ago
- turkeys seem to get a lot of bad press, but they are really pretty smart and great fun to have around http://tinyurl.com/6fstlg — 22 hours 12 min ago
- new iPhone software update today - adds HDR to photos. Sweet! — 1 day 38 min ago
- mmm, donuts - is there nothing they can't do? (including promoting movies) http://tinyurl.com/27gedus — 1 day 21 hours ago
- offensive stereotypes today; good marketing in 1940 http://tinyurl.com/2g7c3c2 oh mama! — 3 days 21 hours ago
- 1 of 170
- ››



Comments
thanks for this, Phil.
most of it works
My biggest problem is I can't run pm-update on sites with Subversion used, because it first moves everything from a module directory to a backup directory, including the .svn files! Yes, cygwin is a bit slow; it also does weird things with file ownerships and permissions some times.
Better not to do a hackintosh number; get a used Mac Mini and run native. You'll still want your Windows box for testing sites, and a "real" mac is going to take less twiddling.