« Mobile Phone Wish List | Home | Programming: Engineering, Science, or Art? »
Ruby on Rails under Windows XP with Cygwin
By Jacob Cohen | January 27, 2008
I like to use Cygwin for development under Windows, as I frequently use standard command line utilities like find and grep, and I find the Windows command line environment to be more painful to use than it is worth.
The first time I tried to get this all running, it was in this sort of hybrid Cygwin/windows mode where running certain applications (such as rails or gem) required using the Windows command prompt, where others (such as running the rails-generated scripts) could be run from within Cygwin.
This proved to be too irritating to manage, so I’ve reinstalled the Cygwin version of Ruby, downloaded RubyGems from source, and rebuilt that using my Cygwin version of Ruby. As a neat gotcha, if the Windows version of Ruby has added “RUBYOPTS=-rubygems” to your environment variables, running “ruby setup.rb” in the RubyGems directory will fail with “ruby: no such file to load — ubygems (LoadError)”. Just unset this environment variable and re-run it, and it should be fine.
Now that I got Ruby and Gem installed under Cygwin, I’ve reinstalled Rails (”gem install rails”). One of the other persistent hiccups I’ve been encountering with my setup is how to get my machine connect to the MySQL database I’m running on a separate machine. I don’t want to install the MySQL server software on this machine just to be able to connect, what I need is just the client libraries. Unfortunately, it appears that the mysql ruby adapter requires bits of the server components of MySQL. It won’t build properly if you build just the client libraries of MySQL.
Now that mysql is installed, Gem can install the ruby/mysql adapter, which will allow my Rails projects to connect to my MySQL database on the other machine.
Essentially, here are the steps in the order needed to get this to work.
- Install Cygwin. Get gcc-core and gcc-cpp (to compiled MySQL), and Ruby.
- Install RubyGems
- Install Rails (gem install rails)
- Download the MySQL source, and build it under Cygwin.
- Install the MySQL Ruby adapter (gem install mysql)
And that’s it. Not as simple as it should be, but not impossible.
Topics: General |

January 28th, 2008 at 1:23 pm
Thanks for that. I have been using a similar setup but wasn’t sure how to move forward with MySQL. As an alternative I have been using SQLite but at some point will need to use MySQL.
Got the basic idea from http://garbageburrito.com/blog/entry/391/a-macesque-rails-development-environment-on-windows but there are a few extra tricks to get it running smoothly.
February 11th, 2008 at 6:08 pm
Thanks Jacob, it would be nice if a lot of these offering were a little more CYGWIN aware. Niggling problems are the hardest to bare.
April 8th, 2008 at 6:28 am
thanks for the tips ! very helpful !