The Problem
I normally do most of my Rails development in Linux, but I do have a Windows development environment setup as well, because most of my non-development time is spent in Windows and I like being able to quickly work on a Rails project without having to switch to my Linux machine.
The problem though with Rails development on Windows is two-fold:
- Ruby and Rails do not cooperate with Windows as well as they should sometimes
- Microsoft doesn’t cooperate with UNIX well at all
So rather than try and lay blame as to who’s fault this is, I’ve developed a workaround work flow that works quite nicely.
Software I Use
To make Rails development easier in Windows, I use:
- The E – TextEditor
- Cygwin (installed at first by e, but customized later on by me)
- puttycyg (because Windows console windows suck)
Installing the Environment
I recommend removing Ruby for Windows (the one-click installer variety) before you get started. It will make things a lot easier for you down the road, and unless you’re doing Ruby for Windows applications development, you won’t need it. I also recommend uninstalling Cygwin as well if you have installed it previously, because the e will automatically setup Cygwin for you with some pretty good defaults.
Download a trial of the E – TextEditor and install it. When you first run it, it will want to install Cygwin. Let it do so. Pick Manual if you want to customize the software. You can choose Automatic though and be just fine, because you can always rerun the Cygwin setup (by going to the Cygwin website and downloading their installer) and add or update features later. If you choose the manual method, it would be a good idea to include Subversion, Git, and perhaps other languages like Python and a C compiler to enable you to use other UNIX software inside your Cygwin installation.
Once you’ve done this, you’re almost ready to go. If you like the Windows console, then you can stop here – but I don’t. That’s where puttycyg comes in. It’s basically a modified PuTTY version that works with Cygwin. Using this program you can connect to your Cygwin instance, but having all the options of display and scrollback that come with PuTTY. Let’s face it, being limited to 2 fonts in the Windows console really isn’t fun. I’m still amazed Microsoft hasn’t fixed this.
Once you’ve done this, you can pretty much proceed with development of Rails application using the same commands you would on a Linux or Mac machine (well, at least with 99% compatibility). You can even access your Windows drives with the /cygdrive/c (replace c with the drive you want to use) path in Cygwin.
Conclusion
While this isn’t the most ideal setup, it works well for most things, and enables you to use Capistrano deployments much more easily than you can in Windows. Git’s native Windows version has a long way to go, and thus the Cygwin near-native UNIX version of Git makes using Git under Windows a far more productive task.
In this guide I’m using the E – TextEditor. You could replace this with any other editor that you like and achieve similiar results. You can even use Vim or Emacs inside Cygwin. Either way, I still recommend using Cygwin, because the native Windows Ruby interpreter and Rails support for Windows will cause you problems down the road.