Development Using Unison on Windows

Submitted by allan on Thu, 11/01/2012 - 21:40
I've been plagued by the fact that at work I do my development on a remote system. This generally isn't a problem except on the rare occasion I want to use a debugger, since I'm a Vim user. However, when that time comes (and it always does), I have to sit there and wait while eclipse "builds" my project. Nothing irritates me more than "Hurry up and wait". Since I started working with Drupal, I've found this to be a very common theme. It's far from the speed that I got out of Zend Framework, or other MVC based frameworks, but it does so much for you. That's where it's easy to get "Drupal blindness". A tool I found that helps mitigate this is Unison. Now, I've done the whole rsync thing and copy my files back and forth.. or used a git repo to check things out locally, and even using a mapped driver via sshfs or dokan, but they are all slow when it comes to eclipse doing it's "scans". Unison takes a lot of the pain out of it... even on windows! So here's what you do for a windows machine!

Install Git

So head on over to git-scm and download git, double click the installer, follow the instructions. Simple as that... You may ask, "Why Git?"
  1. It's a good idea
  2. You are going to need the pre-compiled ssh client that comes with it later.

Install GTK+ 32-bit

This is pretty simple too. All you have to do is run over to GTK's site, and download the GTK+ run time package for 32-bit windows. The Unison executable is 32-bit. That's the reason I specify 32-bit. After you download it, unzip it to C:\Program Files (x86)\Gtk2. This will put it right along next to Git for easy access.

Add Git and GTK to Your PATH Variable

This is one of the least known facts about Windows. You do have a PATH variable just like any Linux distribution (OS X included). To do this, bring up your computer properties. You can do this by one of the following:
  • Windows Key + Pause
  • Right click on My Computer and goto properties
Click "Advanced system settings" Click the "Environment Variables..." button Double click the the "Path" variable entry Type
C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Gtk2\bin
into the Variable value box. Make sure if you type it before anything else in the field, you add a semicolon after it, or if you type it after what's already in the field, you add a semicolon before it. Click a bunch of OK buttons to close all the dialogs out.

Download Unison

I found it difficult to find the exact download link just looking around the Unison pages, so here is the direct link to Unison 2.40. Unzip the zip you get and place Unison somewhere you won't lose it. My desktop worked fine in this case.

Set Unison Up On Remote Machine

Unison is availaible for all sorts of operating systems. In my case, I have a Ubuntu box I'm working with so all I did was a simple:
sudo apt-get install unison
on the system that I wanted to sync with. This will involve you remotely accessing your other machine... In my case that means ssh. Man I wish it had been that easy to do it in Windows!

Set Up a Profile on Local Unison

When you double click on the Unison Icon, you will get something that looks simular to this: I've already set up my profiles though... Click on "Edit" to edit your default profile. Then click "Add" on the next dialog to add the folders we want to sync Go down and pick out "root" and click "Add" Click the new "Add" button on the next dialog titled "Edit the Preference" Type the folder you wish sync into the "Edited Item" field Click the "Edit" button. Repeat the steps for your remote file system. For me it was something along the lines of:
ssh://allan@my.sandbox.com//var/www/drupal-7.14
There is very exhaustive documentation on roots over in Unison's user manual. Click OK until you get back to the "Profile Selection" dialog

Sync Your Directories

Hit "Open" If you used SSH, you may need to supply a password. Watch the command prompt in the background! Sync and Code!

Final Thoughts

Using Unison is one of the best time savers I could have implemented, probably next to drush. Windows sometimes takes some getting used to, but to be honest I use it because I'm too lazy to install something else on the machine I wish to use as my "Gaming machine". With that said, Unison has fully stomped my expectations. The only thing that would make it better is if it auto synced for you where you didn't have to tell it to sync every time you make a change. However, that is definatly something I can live with!