A Mac-esque Rails Development Environment on Windows
Here's the deal, as I've said before, I like Windows and I love Vista. Mac's certainly are beautiful; but as of yet "It just works" is not convincing enough for me. However, any Railer will tell you that the holy grail of Rails editors is TextMate, which of course is Mac only. I've come to believe that TextMate is not just the favorite Rails editor because a titanium Mac Book looks good with DHH's blazer, but there is also a common philosophy between them. A simple elegant language should have a simple and elegant editor. So therein lies my delima.
Throughout the creation of my website builder, doodlekit, many different editors/environments have come and gone. I've been eyeing e (three times fast), and it's really shaping up to be a very nice TextMate clone for Windows. Even before that I fell in love with Console, which makes the Windows command line pleasurable. And cygwin is of course more than capable of running a Rails environment. All the pieces have fallen into place, and I have a recipe for a very nice Rails development environment on Windows.
Notes: I did this on Windows Vista Ultimate 64-bit, but I think it should be the same for all Windows versions. This guide assumes you have a novice understanding of Linux/cygwin. And finally, I’ll leave choosing and installing a database to you.
Step 1 - Install e
Be sure to pay for it once you've decided to keep using it.
Step 2 - Install cygwin
E relies on cygwin for some of the bundles, which is ok since our Rails environment will also be running in cygwin. Start e after it's installed. If a dialog titled "Update Cygwin" doesn't popup right away, click on some of the bundles till it does.
Select the "Manual" radio button and click "Next".
The default options should be good until you get to "Select Packages". Make sure Ruby, Subversion, and any other Packages you might need are selected to install.
Finish the cygwin installation
Step 3 - Install Console
Console is probably my favorite thing ever. It's a command prompt replacement for Windows with tabs, transparency and other funky jazz.
Make sure you grab the very latest build.
You'll want to setup cygwin as a Console Tab. Just go into the settings and click "Add" under "Tabs". Use the following as the "Shell".
c:\cygwin\bin\bash --login -i
If you want it to automatically open cygwin when you start Console, just move it to the top of the Tabs list.
Step 4 - Install Ruby Gems
Download, un-tar, and run the setup ruby script. You'll probably get an error that says "No such file to load -- ubygems (LoadError)". Just run the following command to get around it.
Step 5 - Install Gems
Now just install rails and all the other gems you need, as you normally would. Keep in mind that you are in cygwin, so do NOT choose the win32 versions of the gems
gem install rails --include-dependencies
Step 6 - Setup e Alias
This last step is optional. If you're familiar with TextMate, you can open it from the command line use the 'mate' command, but more importantly you can open the current directory as a project by using 'mate .'. e does the same thing, however when you do this in cygwin, it retains control of the shell instead of running it in the background. I came up with a way to handle this, but Charles Roper in the e forums had a better way.
First make sure e is in your $PATH, either through the Windows or cygwin environment variables. You can test this by just typing 'e' from cygwin and hiting enter. To make e run in the background add this to your .bashrc file.
alias e='cygstart e'
Step 7 – Test it Out
Open Console, and make sure you’re on a cygwin tab. Create a rails project as normal.
Go into the new directory and open e.
This will open e with your new project loaded into the project explorer.
That’s it! Have fun.