Installing Rails 3.1 and Ruby 1.9.2 on windows

First off, Engine Yard released another Rails Installer, which contains 1.9.2 and rails 3.1 with Sqlite, SQL Server support, git, etc. So if you want a quick development environment, that's probably your best bet. I haven't tried it out myself, but that installer is built by some smart people. If you wish to install 1.9.2, rails 3.1 through bundler and setup MySQL separately, feel free to keep reading.

Note that these instructions also work with 1.9.3.

Install Git


To be honest, github does a much better job on describing how to install git then i ever could, and if you wish to use a github account, their are some essential steps to follow here anyways:

Just Git

In short, grab the latest git installer. When running the installer, i select most of the default options.


When you are asked to select one of three options, the default being "Use Git Bash only", choose the middle one. I personally like having git on the PATH variable for when using CMD.

Installing Ruby and dev kit

Grab the ruby installer from, as well as the development kit link. Run the installer (be sure to check any options for adding it to the path).

After downloading the devkit, run the executable and select a directory to extract, such as C:\DevKit. In CMD, type:

cd <Devkit directory from previous step>
ruby dk.rb init
ruby dk.rb install

For more detailed instructions, have a read here

Installing Rails

To get Rails, the next step is to install bundler. You need bundler for when creating your application, since a Rails app uses bundler to manage its required gems.

gem install bundler

Once that's done, simply use:

gem install rails

Installing MySQL

I've tried a few different versions, and I had the best luck by installing XAMPP 1.7.5. Just use the default install path on the C:\ drive. Just make sure when you need to run an app to use the control panel to start up the MySQL server.

Now, to install the mysql2 gem, use the following command:

gem install mysql2 -- --with-mysql-lib="C:\xampp\mysql\lib\opt" --with-mysql-include="C:\xampp\mysql\include"

If you ran into errors, double check that the paths in the above command resolve on your system. If not, please post a comment, and your error message output using Pastie so I can hopefully help you figure it out.

Creating a rails app

From here, I recommend checking out the getting started guide on the guides website. However, you need one little modification:

rails new blog -d mysql

The -d option is very important, so it knows to use your install of mysql.

There should now be a folder called blog. In there, browse to config/database.yml, and open that in an editor. Change the username and password as need be. Now run:

bundle install

and be sure that everything installs correctly, and that you don't run into errors. This is automatically done when you create the app as well.

Further reading

To continue learning the basics, i suggest picking up the guide from where I left off