OK, so I found out what it is that I have to install for my wonderful Ruby on Rails environment. It’s time to start installing.

Keep in mind that much of what I’m doing here is an experiment (and thanks Luis for being so patient with me). I don’t claim to know what works and what doesn’t, I’m just trying to find my way around here. Follow my steps at your own risk – they seem to lead to a working environment for now.

Update 2009-07-03 02:16: There’s a followup post now that does less evil and wrong things, hopefully. It also happens to result in a working Ruby on Rails plus MySQL environment, something this post doesn’t quite achieve.

Getting Ruby to run

Admittedly, I was a little surprised by how easy this was. Get Ruby and the Development kit from here. Extract them (using 7-Zip, which you should use by default anyway), and put all the contained directories where you want your Ruby. Mine resides in F:\Ruby.

Next, add the newly installed bin directory to your path. Quickest way: Open the control panel, search for “environment”, then click “edit the system environment variables”, and add the bin after a semicolon to the “Path” variable. Then, change the path in devkit/msys/1.0.11/etc/fstab to where you put your stuff – you won’t have to do this if you put Ruby into C:\Ruby.

This is what we get:

Ruby Installed 300x166 Actually Installing Ruby on Rails, on Windows 7

Ruby Installed

Yay. That was easy. And the greatest thing is that the One-Click installer (even if it’s not entirely one-click, currently) also already adds support for Ruby Gems.

Getting Rails

The next step is to install some gems. There is a long list on Akita on Rails, but after realizing how little stuff works with Ruby 1.9.1 and Windows 7, I chose to (nearly) only install the things I need:

gem install rails

This installs Rails and the gems it depends on.

ImageMagick, and Some More Stuff

Next, since I planned to do so and not out of some technical necessity, we install ImageMagick for Windows – get the newest Win32 Binary Gem version from RubyForge and extract it somewhere. Install the gem by going into the directory it’s extracted into and then executing this:

gem install rmagick-2.10.0-x86-mswin32.gem

Substitute the gem name with the version you’re actually using. Then install ImageMagick itself, with the .exe that you just extracted as well.

If you’re like me, you won’t be able to resist attempting to install some more gems. Here’s a nice video with some suggestions from Railsconf 2009. Personally, I installed googlecharts, twitter, cucumber and pdf-writer, but haven’t gotten to try them out properly yet.

Testing What We Have

We have Ruby on Rails now. Yep, that’s it. Rather painless so far, eh? Test it by going to the directory you want your projects in and typing this:

rails testproject

You’ll see Rails creating plenty of directories and files now. After it’s done, do this:

cd testproject
ruby script/server

Point your web browser to, and you should see Rails, in all its glory:

Rails Installed 300x233 Actually Installing Ruby on Rails, on Windows 7

Rails Installed

Not Installing MySQL

I started out by attempting to install MySQL 5.1, thinking it was stable and all. However, as it turns out, there are plenty of problems with that, and none of them stem from MySQL:

  • The mysql gem relies on libmySQL.dll, which has to be in the path.
  • The mysql gem is precompiled, there is no 64-bit Windows version, and the 32-bit version relies on msvcrt-ruby18.dll, rather than the newer msvcrt-ruby191.dll.
  • There is a segmentation fault that I haven’t found the cause of.

I was able to fix the first two problems by adding the mysql/bin directory to the path, and installing a Ruby 1.8.6 alongside the Ruby 1.9.1 to get the 1.8 DLL – but nevertheless, I never got rid of that segmentation fault, despite multiple reinstalls and even trying MySQL 5.0 instead of 5.1 (Google search for the exact cause, none of the proposed solutions helped).

(Do not install the 1.8 DLL, that’s apparently very evil.)

Nothing worked until I gave it a try with Ruby 1.8.6 (after all, I had that installed from attempting to get that DLL, and only needed to change the path variable and install the rails gem to have a go), and lo and behold everything worked fine.

Which convinced me not that I should use Ruby 1.8.6, there’s too many shiny new features in 1.9.1. Instead, it convinced me that I should forget about MySQL.

Installing PostgreSQL

Since Rails migrations make database dependencies a thing of the past (or at least, to a very, very large extent), I decided to install PostgreSQL instead. Their one-click Windows installer for PostgreSQL 8.3 worked a treat and installed the service and everything just fine. Next step, have Rails be able to talk to it – there are two PostgreSQL gems, only one of which (postgres-pr, not ruby-postgres) currently seems to work in Windows. So let’s get it:

gem install postgres-pr --platform=mswin32
Create Role 150x150 Actually Installing Ruby on Rails, on Windows 7

Create Role

(Not sure if the platform is necessary, but it can’t hurt.)

Set up a database user (“login role” in PostreSQL-speak) with pgAdmin – I called mine rails – and give it a password and the ability to create databases.

Now we change the database.yml in the project’s /config/ directory. Open it with some text editor (I like EditPlus myself) and change it to fit your configuration.

This is the database.yml that makes my test project fly:

 adapter: postgresql
 database: testproject
 username: rails
 password: ***
 pool: 5
 timeout: 5000
 host: localhost

Note that host:localhost (or the equivalent for your database) is important, as otherwise Rails will attempt to connect to PostgreSQL using UNIX Sockets – which obviously wouldn’t work. After that, let’s test. Go to your shiny rails project in a command window, and type or paste these:

ruby script/generate scaffold test title:string description:text
rake db:create
rake db:migrate
ruby script/server

After that, point your browser to and poke around a bit. You should have your first Rails app running, including all four CRUD actions.

CRUD Running 300x199 Actually Installing Ruby on Rails, on Windows 7

CRUD Running

I Think I’m Done Here

Done after installing aforementioned Firebug (just click “install”), Web Developer (yep, “install”) and Git for msys from Google Code (which seems to work fine so far). There’s a Ruby gem for Git, too; install with this:

gem install git

I then also got gVim 7.3 – not for the faint-hearted, I do have some experience with vim from coding Python on Linux though. I will also test how well editing works with my EditPlus, and probably some IDEs. Either way, I’ll probably make a little personal user interface evaluation post later on.

Looking back to the assessment post, I’m actually not done at all. The following things are still missing – most of them, for a reason:

  • ruby-debug doesn’t work with Ruby 1.9.x yet, so that falls flat. It’s merely a wrapper for the built-in debugger though, so I will be able to debug anyway.
  • Mongrel has “ruby script/server” produce another segmentation fault, and I don’t want to spend another 7 hours for not finding a solution to it.
  • Apache doesn’t make much sense in a pure development environment, particularly not if we don’t have Mongrel anyway.
  • Subversion has plenty of versions on their download page. I downloaded the one from Slik SVN myself, but haven’t installed it yet until I actually need it. So that’s technically missing, too.

Where To Go Now

There are some resources that can get you started with your most splendid new Ruby on Rails environment. If you have no idea what Rails is yet or why you should use it, have a look at this presentation. I found the Head First Rails book to be a very good introduction, too. Concerning Ruby, Why’s (Poignant) Guide to Ruby (available as pdf, too) is both free and great, albeit talking about Ruby 1.8.2, a tiny bit outdated. If you like it thorough, get the book only known as the Pickaxe. It is as good as they say.

Thanks for listening, and I hope I can help one or two among you out. You like it? You hate it? You found something I didn’t? Let me and all your fellow readers know in the comments!