Installing Ruby 1.9.1, Rails 2.3.2 and PostgreSQL on Windows Vista

This is a short write up on how I installed my Rails development environment on Windows Vista. If you have any trouble, consult the notes section at the bottom.

Update: I missed the part about installing the devkit, thanks to Roger Pack on the Rubyinstaller-devel mailing list. I also added a section for references.

Downloads

You’ll need to download the following:

Installing PostgreSQL 8.4

Installing PostgreSQL is rather simple, just follow the wizard.

PostgreSQL 8.4 Installer Welcome Choose your installation directory

Choose your data directory Configure service account password Configure listen port Setup default locale Installing PostgreSQL 8.4 Initializing the database cluster Installation success

Installing Ruby 1.9.1

Ruby 1.9.1 preview installer welcome GPL License Installation directory Installing Ruby 1.9.1 installation success

Installing the devkit

Extract “devkit041109.7z” to your ruby path, “C:\Ruby19”, after which you should have the following directory:

  • C:\Ruby19\devkit

Also, edit the file “C:\Ruby19\devkit\msys\1.0.11\etc\fstab” to contain the following:

C:/Ruby19/devkit/gcc/3.4.5 /mingw
C:/Ruby19/devkit/msys/1.0.11/usr/local /usr/local

Installing Rails and the pg gem.

The Ruby installer added a “Start Command Prompt with Ruby” to the Start Menu, go ahead and run that now.

  1. Add the PostgreSQL bin directory to your path.
  2. Install rails.
  3. Install the pg gem.
set Path=%Path%;C:\Program Files\PostgreSQL\8.4\bin
gem install --no-ri --no-rdoc rails
gem install --no-ri --no-rdoc pg

rails_pg_step01_to_step03


That’s it, go develop that killer twitter client, its what all the cool kids are doing.

Notes

  • If you had previously installed PostgreSQL, remove the service account user with “net user postgres /delete”.
  • Copy “C:\Program Files\PostgreSQL\8.4\bin\libeay32.dll” to “C:\Ruby19\bin” if you encounter an error when Rails attempts to connect to your database.

References

5 comments:

Roger Pack said...

Nice tutorial.

silnara said...

Thank You Very Much

Fernando said...

Thank you so much, I started before i found your tutorial and was having a hard time figuring out what i did wrong. I am newbie to all the components and in a rush. My Installation:
- Windows Vista Business
- Ruby 1.8.6 (Couldn´t find the one click installer for the 1.8.7 recommended by rails.) The book im using to learn rails didn´t advice to use Ruby 1.9 either so i stayed behind.
- Rails 2.3.4
- Same PostgreSQL 8.4 installer.

My mistake was trying to use the Advanced Server with Postgres 8.3.8, and the pg gem missed the 8.4 libpq.dll, so i did the "set path" update and replaced libeay32.dll but also ssleay.dll.
Voilá! it works!
I didnt installed yet the developer kit so i´m going to find out first what is it for. I was about to drop the windows development for the linux one but saved the frustration with your help. There is much less Rails/PG advice than, lets say MySQL so i appreciate this a lot.

Matt Haley said...

The devkit is needed to install/compile native gems on Windows, for instance nokogiri.

Anonymous said...

I recently upgraded to Ruby 1.9.1 using the new installer for windows (rubyinstaller-1.9.1-p243-rc1), and running on Vista. After reinstalling all of my gems, I had a mysterious error every time rails tried to access my Mysql database, sometimes crashing the Ruby interpreter. I had already placed a copy of the libmysql.dll file in the Ruby19 bin and the Mysql gem (2.8.1) was working fine from a separate ruby program or the interactive console. I finally discovered after some trial and error that the libmysql.dll file in the ruby bin needs to be from a Mysql installation version 5.0 or earlier. After changing this libmysql.dll file, rails works fine, even when running on later versions of Mysql (I'm using 5.1.40).

Also, my application was frozen to rails version 2.3.4, which was causing a different set of problems with ruby 1.9.1. When I changed to rails 2.3.5, everything was running smoothly again.

Post a Comment