Getting a working Rails stack on Windows can be a frustrating experience. Rails was born in the Linux/Unix world so there are many libraries assumed to be on your system, but are not part of a regular Windows OS installation. Below I share my own personal experience with getting up and running with Ruby and Rails using JRuby, which for me was the best way to go.
Requirements
Note the links above might move or change so you can visit (java.sun.com, www.jruby.org, www.postgres.com) and poke around to find them.
Installing Java and JRuby
This part is very easy. Just double click the Java installer and follow the directions. It will install Java to a location in your C:\Program Files (or the location you specify). Do the same with JRuby. I like to have JRuby live right under C:\jruby-1.4.0 so it is easy for me to get to (by default it will also go under C:\Program Files).
Now we need to edit our Windows environment and make sure that JRuby and Java can be seen on the path. You’ll want to go to your Start > Control Panel > System > Advanced system settings and click the Environment Variables button.
You might already see a JAVA_HOME value under User variables (and that’s ok). You might even see one for JRUBY too. I like to have the environment variables for Java and JRuby available at the system level however.
Click New under the System variables section and add entries for JDK_HOME and JRUBY_HOME as you see in the example on the right. Click OK when you’re done.
Now open a command prompt window (Start > Accessories > Command prompt) and type in echo %JDK_HOME% and hit enter. You should see the value you set, do this for (echo %JRUBY_HOME%) as well. Both should return the values you set previously in the Environment Variables window. The last thing to do is add these values to your PATH.
Return to the Environment Variables window and edit the PATH value under system variables by selecting it and hitting Edit. Entries are separated by a semi-colon (;) so make sure you add one to the front of the entries you’re adding unless there is one already there:
;%JDK_HOME%;%JRUBY_HOME%
Now after that’s done close and reopen your command prompt window (so that the new values are loaded). Type echo %PATH% and you should see the two paths at the end of the results:
>> echo %PATH% C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files(x86)\Git\cmd; C:\Program Files\Java\jdk1.6.0_17;C:\jruby-1.4.0\bin
Now that all our paths seem in order we can further verify everything is working right:
>> java -version java version "1.6.0_17" Java(TM) SE Runtime Environment (build 1.6.0_17-b04) Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)
>> jruby -v jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02) (Java HotSpot(TM) 64-Bit)
Welcome to JRuby
At this stage you should have a working copy of JRuby. JRuby is just like Ruby, except it uses Java and not the MRI/YARV interpreter. Most of the commands you might be used to on a regular Ruby stack work the same in JRuby, except often you use jruby -S to run your commands rather than ruby. Let’s start installing a few of my favorite gems:
jruby -S gem install rails haml nokogiri shoulda factory_girl cucumber webrat ^ rspec rspec-rails will_paginate ZenTest redgreen fastercsv RedCloth paperclip ^ nifty-generators jruby-openssl
That should be plenty to get you going on most any Rails/Ruby project. Watch the output as the gems are installed, rarely should you run into trouble. If a gem is complaining about installing you can add the –platform=java flag to the end to try and force it to install under the Java platform (for example):
>> jruby -S gem install grumpy_gem --platform=java
Connecting to Postgres
You probably can use any Rails supported database, but I prefer Postgres. It’s a free database that is available on a variety of platforms (much like MySQL) but a little more powerful. I also find it easier to work with on JRuby so it’s the one I’ll use here.
Run the PostgreSQL installer. Follow the on-screen directions. During the installation, however it is important to make sure you install the optional JDBC drivers, don’t forget this step (if you do you will have to run the Postgres Stackbuilder application later and install them).
The installer is going to add a ‘postgres’ user onto your system and require you to restart at some point. Once the installation is completely finished you can open your command prompt and install the Rubygem for connecting to Postgres:
>> jruby -S gem install activerecord-jdbcpostgresql-adapter
I am not going to go into details about how to set-up users, etc. in Postgres. You hopefully are familiar enough with database software to know how to do there is plenty of information on the Web to figure this out, just Google it. Postgres comes with some nice GUI tools that make it easy to do and it is pretty straight forward.
Now there is one caveat with the Postgres ActiveRecord adapters and JRuby. There’s a known issue with creating and dropping databases in Rails. So in order to get things like rake db:create:all to work you need to type inside your Rails application root:
>> jruby -S script/generate jdbc
That is pretty much all there is to getting a full stack up and running on Windows. I have started developing in the past week using JRuby on Windows along with Rubymine as my editor and GIT as my source control. I’ve been pretty happy with it thus far. I still enjoy developing most on my MacBook Pro – but it was a fun experience exploring JRuby (I’ve been playing with JRuby and Ant working together).

Nice write-up. One note though. I think that if JRuby installer is used on Windows, it will adjust the environment variables itslef, hence there will be no need to do that manually. One step less
Yes, and you can even get a version of the install with the JRE included. If you are a control freak like me though – you’ll want to know what your PC is doing. It’s good for someone installing it for the first time to understand the PATH because its critical to getting it working right and a first step in troubleshooting any problems.
Great feedback though, thanks for pointing that out!