Ruby on Rails
RailsonWindowsCygwin

For those of you who prefer Windows as your development environment, yet are NIX-inclined, here is a way to install Ruby on Rails for development & testing use under Cygwin.

When you’re done, all your command prompt work can be done under Cygwin.

At the time of this writing, Cygwin includes Ruby 1.8.4 and MySQL is on verison 5.0.

For an alternative using SQLite3 see RailsOnWindowsCygwinWithSQLite3.

(Note: I just went through this and didn’t find all the issues covered in one place, so I put this together. Feel free to refactor, I’m a bit of a rails noob.)

(Note: I have successfully installed Rails 2.0.2 with MySQL on Cygwin without requiring steps 3, 4, and 6 (installation of mysql gem). Several caveats do apply however and are noted in the “Common Errors” section below.)

1. Install Cygwin

Run Cygwin’s setup.exe as normal (for expanded install instructions, see below). From the package list, under Dev, make sure to choose:

You’ll be using gcc to build the Cygwin version of MySQL, even though you will not be running it (see below).

2. Install MySQL for Windows

Just download MySQL 5.0 Windows Installer. I used the full version as opposed to the Essentials version.

This will install MySQL as a Windows service, meaning it will be running full time. Follow the installation wizard for security settings, etc.

3. Install MySQL generic source package & build it

This is at the bottom of the page and is labeled Tarball.

Extract the tarball into a tmp directory and do the normal Linux things:

This will take a bit. You’re compiling MySQL 5.0 for use under Cygwin. You’re not going to run this version, but you need it around, especially the source, in order to build the Rails MySQL connector below.

4. Install Ruby Gems

Do this the normal way. Download Gems and do the normal extraction and then execute ruby setup.rb

5. Install Rails

Now that you have Gems, you can install Rails. Execute gem install rails --include-dependencies

If you are behind a proxy, use -p (for full documentation, see the GEMS Manual). This applies to step 6 below as well.

since Rails 2 is out, I find that adding—version 1.1.6 to this command is important

6. Install the MySQL Gem

Execute gem install mysql. When prompted for the choice, do NOT install the mswin32 version. Install the latest unix version.

That’s it. Ruby scripts, Rails commands, and connections to MySQL should now work.

Expanded Install Instructions

For those of you new to rails, cygwin is VERY helpful, since Winblows isn’t the greatest environment for development (also, I’m too poor to buy a Mac and my HD can’t hold a linux partition… woe is me.) Here is the straightforward way to do this:

Common Errors