Sunday, November 20, 2011

How to build Ruby on Cygwin and setup Heroku

I like to use ruby that comes with Cygwin instead of the RubyInstaller for Windows, because the path it handles are more consistenly in Linux form. But the current Cygwin only comes with ruby-1.8.7, so to use ruby-1.9.3, I have to built it on Cygwin on my own. And when building ruby from source on Cygwin, you would also have to install gem on your own as well. Turns out there are few issues that you have to fix too. Here are the steps I got it working:

0. Ensure you have the typical Cygwin/Linux build tools (gcc, make, autoconf, libiconv, openssl and etc.)

1. Download source for the following:
  a) LibYAML 0.1.4 from
  b) ruby-1.9.3-p0 source from
  c) rubygems-1.8.11 from

2. Unzip/tar them all in /tmp
  a) $ cd /tmp/yaml-0.1.4 
     $ ./configure && make && make install

  b) $ cd /tmp/ruby-1.9.3-p0/ext/openssl
     $ ruby extconf.rb
     $ make && make install

  c) $ cd /tmp/ruby-1.9.3-p0
     $ export CPPFLAGS=-I/usr/local/include
     $ export LDFLAGS=-L/usr/local/lib    
     $ ./configure && make && make install

  e) $ cd /tmp/rubygems-1.8.11
     $ ruby setup.rb

With these completed, you may now install Heroku client tool as ruby gem:
  c) $ gem install heroku
You would also need Git to successful push and deploy application to Heroku, but you can get Cygwin 'git' package if you haven't already done so.

NOTE: FYI, all the user built applications are usually install into /usr/local directory, while those system (comes with cygwin packages) are in /usr.


  1. Hi Zemian,

    Thank you for writing up these very helpful instructions. I found one small error, the first line for installing openssl should be

    b) $ cd /tmp/ruby-1.9.3/ext/openssl


    b) $ cd /tmp/rubygems...



  2. This is great, although I had to flay it and re-arrange it to make it work on my system.

    Steps 0 - 2; no problem
    Step 3: There is no "ext/openssl" path in the rubygems directory, but there is in the ruby directory. like So I skip ahead: to step c. Besides, why am I installing gems before ruby?
    Step e: installed great.
    Step b: installed great.

    Maybe it's because I'm on a 64-bit Win& machine?

    1. Hello Kyle,

      Yes you are correct, and so did Phillip mentioned a while ago. I just didn't get a chance to correct my typo. I've corrected it now.

      Thank you for the feedback.