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.

windows and ruby

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.

ruby installer

  • 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

installing rails

  • Downloaded SQLite3 Windows DLL from the official download page and extracted it to the Ruby bin directory (use gem env to determine the path)

gem env

  • Created the 6-command blog program. (cd blog not included in pics)

rails new blog

bundle install

rails generate scaffold

rake db:migrate

rails server

  • Opened http://localhost:3000/entries in a browser. Works as expected.

open browser

Conclusion: Ruby 1.9 on Windows is pretty fast. Have the newbie install this along with NetBeans or RadRails and he should be diving into Rails in no time.

Virtualization (my personal choice)

virtual machine

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.

JRuby

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.

Tagged with →  
Share →

2 Responses to Ruby on Windows

  1. […] that post about Ruby on Windows? Well, one thing led to another and PhRUG thought it was a good idea to fork the RubyInstaller to […]

  2. Pepe says:

    Hi there. I was one of the attendees for the Ruby on Rails seminar that you presented in FEU – East Asia College earlier today.

    Honestly, I dislike Apple. The whole goals of the company and their paradigm shift by the time OSX came along was a big disappointment for me. Telling other people to get a Mac to create OPEN-SOURCE applications is totally inconsiderate, and illogical. As long as you get the support you need, that should be enough, and this post simply proves that no matter what OS you use, you can get that support.

    Thanks for the insight in this world of ever-increasing software loyalists 🙂

Leave a Reply

Google+