Windows + Ruby Native Gems (1.9.1)

A few weeks back I posted about getting the ruby-debug-ide gem installed in Windows under Ruby 1.8.6.  In that post I outlined how hacking a header file and using the Visual C++ 2008 compiler could be leveraged to get the gem built and installed properly.  Well, after a helpful comment from a reader and watching a few screencasts over on TekPub, I actually found a way to do this with Ruby 1.9.1 from RubyInstaller.org.

As you know, I swapped my Windows development environment for Mac OSX, and so far learning Rails has been a great pleasure thanks to Agile Web Development with Rails (Third Edition) from The Pragmatic Programmers.  When I found this alternate method for installing ruby-debug-ide I decided to fire up my Windows 7 VM and give it a go.  Here are the gems I have currently installed on my VM:

ruby-debug-ide-1.9.1

To get this working on my VM, here’s the steps I followed:

  1. Install Ruby 1.9.1 from RubyInstaller.org.  When you run the installer, make sure you pay attention to the checkboxes under the install path and check both of them:
    ruby-installer-associations
  2. Now that you have Ruby installed, you need to get the devkit package from Rubyforge.  You should see an archive in the “Development Kit” section of that page.  The current version as of this writing is 3.4.5r3 (20091110).
  3. Once you have the archive, you’ll need 7-zip to decompress it, so go get it and install it.
  4. When you open the archive in 7-zip, click the Extract button and make sure you extract it to wherever you installed Ruby.  In my case this was C:\Ruby19.
    ruby-devkit-extraction
  5. The last step is to make the devkit fstab file point to the proper Ruby folders.  The fstab file is underneath your Ruby install.  Mine was located at C:\Ruby19\devkit\msys\1.0.11\etc\fstab.  Just open this file in notepad and change it.
    ruby-devkit-fstab
  6. Now the devkit is installed properly, all you have to do is open up a command prompt (make sure you Run As Administrator) and type the following commands (if you want to get the same gems as me):
    gem install rails
    gem install mongrel
    gem install cucumber
    gem install rspec
    gem install ruby-debug-ide

That’s it!  If you run into any weird issues, let me know in the comments.  Enjoy your new Windows-based Ruby on Rails development environment running the latest and greatest Ruby 1.9.1! :)

Tags: ,

  • Shafi

    please help me . when I wrote “gem install rails” after few minutes  I had following error.

    Building native extensions.  This could take a while…
    ERROR:  Error installing rails:
            ERROR: Failed to build gem native extension.

            C:/Ruby192/bin/ruby.exe extconf.rb
    checking for re.h… *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of
    necessary libraries and/or headers.  Check the mkmf.log file for more
    details.  You may need configuration options.

    Provided configuration options:
            –with-opt-dir
            –without-opt-dir
            –with-opt-include
            –without-opt-include=${opt-dir}/include
            –with-opt-lib
            –without-opt-lib=${opt-dir}/lib
            –with-make-prog
            –without-make-prog
            –srcdir=.
            –curdir
            –ruby=C:/Ruby192/bin/ruby
    C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:368:in `try_do’: The complier failed to generate an executable fil
    e. (RuntimeError)
    You have to install development tools first.
            from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp’
            from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:834:in `block in have_header’
            from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for’
            from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone’
            from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open’
            from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone’
            from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open’
            from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:276:in `postpone’
            from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for’
            from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:833:in `have_header’
            from extconf.rb:14:in `’

    Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/json-1.6.1 for inspection.
    Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/json-1.6.1/ext/json/ext/parser/gem_make.out