Since I’m one of those windows ruby developers, I was so interested to give Rails 3 a try. What was stopping me was the ruby version limitation that Rails 3 now has as it requires ruby 1.8.7 at least.
Since most of us, windows developers, use the ruby one click installer, we were stuck at 1.8.6. Luis Lavena, however, have just released RubyInstaller RC2 with an installer for 1.8.7 which resurrected my hopes for running Rails 3 on windows.
I wanted to give Rails 3 a try by converting an existing app to Rails 3. A major show stopper is the mysql gem which refused to install because the native extensions did not build when doing
gem install mysql
I read the tutorial on Getting started with Rails and Mysql but I had Mysql 5.1 so I really wanted to be able to build the gem’s native extensions.
- Old ruby installer at C:ruby1.8
- Mysql 5.1 at C:Program Files (x86)MySQLMySQL Server 5.1
What I did
- Install RubyInstaller 1.8.7 RC2 at C:ruby187rc2
- Modified the environment variables to point at the new ruby’s installation
- Install DevKit from http://rubyinstaller.org/ and follow its installation instructions from http://http://wiki.github.com/oneclick/rubyinstaller/development-kit
- Since I don’t have mysql’s bin directory in the Path environment variable, I copied the file libmySQL.dll from C:Program Files (x86)MySQLMySQL Server 5.1bin to C:ruby187rc2bin
- I found several blogs pointing out how to build the mysql gem for the RubyInstaller but they all required that Mysql be installed in a directory that had no spaces. The problem is I already have mysql installed at a directory with spaces, so I used the following command to fake mysql’s location into some place with no spaces
mklink /J C:mysql51 "C:Program Files (x86)MySQLMySQL Server 5.1"
- Install mysql gem using the command
gem install mysql –platform ruby — –with-mysql-include=C:mysql51include –with-mysql-lib=c:mysql51libopt
and everything now works like a charm :)