Some posts just write themselves. Today’s post comes from my reply to a guy in PhRUG who still thinks you need a Mac before you can develop Rails applications.
This is probably the biggest problem the Ruby/Rails community has when trying to spread the word in this country: the lack of interest in supporting Windows.
I mean, a typical response to the legitimate question “I’m using Windows, how to I practice RoR?” is the fanboy answer: “Get a Mac!”
And that, my dear readers, is a dick move. If I was an average college student and you told me that, I’ll immediately think “WTF?!? I just want to try out this open-source language and web framework and I need to shell out a couple of years worth of tuition?!?”
Answering “Format your hard drive and install Linux” is less of a dick move, but a dick move nonetheless.
Thus, if we rubyists want to spread the word about Ruby, we’ll have to make Windows a viable OS for Ruby development. Here are a few options available to us:
Use Ruby 1.9.2
Startup speed is probably the main problem with developing Rails in Windows. Fortunately, Ruby 1.9 is a heck of a lot faster than 1.8 thanks to the new interpreter.
I tried to install Rails 3 on my gaming rig just now to see the difference.
- Downloaded and installed the 1.9.2 installer from the official ruby site. Note that you must tick the Add Ruby executables to your path to remove the need for doing that later.
- Went to the command prompt (I used PowerShell because it’s just better) and installed Rails 3 using the same command for installing it in Linux or OS X:
gem install rails --no-ri --no-rdoc
- Downloaded SQLite3 Windows DLL from the official download page and extracted it to the Ruby bin directory (use
gem envto determine the path)
- Created the 6-command blog program. (
cd blognot included in pics)
- Opened http://localhost:3000/entries in a browser. Works as expected.
Virtualization (my personal choice)
The problem with Windows is that some important gems (rvm, unicorn, and passenger) are not supported by the OS. Fortunately, with a decent computer, you can run Linux inside of Windows without having to dual boot. VirtualBox or VMWare Player are both free virtualization options available on Windows.
For a gaming level rig (~4 GB RAM, RAM is pretty cheap nowadays), installing Ubuntu Desktop 10.4 (Lucid Lynx) on a VM with 10GB of space and 1GB of RAM should be more than enough for development needs. If you want to use a Windows editor/IDE to edit your files, you can setup shared folders to gain access to the files from the host PC.
For a slightly weaker machine, you could install Ubuntu Server on a VM with 10GB of space and 512MB of RAM, and voila! instant VPS on your PC. You can even use openssh-sever + PuTTY to emulate having multiple terminal windows.
Pretty much the same as MRI Ruby with some minor differences. We don’t have rvm on Windows so you’ll have to change all of your “
ruby” commands with “
jruby” and prefix your ruby system commands with “
jruby -S” e.g. “
jruby -S gem ...“.
Downside is that it has the slow startup speed of 1.8 (they say you could tweak it to preload the libraries faster, but I haven’t tried it myself) and the native extension problems of having a different environment.
On the plus side, it’s on the JVM: just package your project into a WAR file with Warbler and it should be deployable on any J2EE application server. Great for convincing J2EE software houses to try out Rails.
In closing, if you’ve got a MacBook Pro and someone asks you about developing Rails on a PC, don’t be a dick and tell them “Get a Mac!”. Ruby is just fine regardless of whether you’re using Windows, Linux, or OS X.