Ruby installation version 1.8.7 & 1.9.1 on win32 platforms with rubyinstaller

Posted by superuser Fri, 26 Feb 2010 08:41:00 GMT

Luis Lavena and the rubyinstaller group have made 2 very reliable versions of Ruby programming language for Windows platforms.

Unlike the old ruby installer, the 1.8.7 and 1.9.1 versions have been compiled with the MinGW compiler(v. 3.4.5) toolset. Easy installing for Windows is essential for the future of Ruby in the programming jungle, and RubyInstaller works perfectly good.

This article should be intended as a minimal guide to install both Ruby 1.8.7 and Ruby 1.9.1 on win32 platforms.

  • Uninstall any previous installed Ruby version and remove the relative folders (for ex. C:\Ruby and/or C:\Ruby19 )
  • Install Ruby 1.8.7-p249
    • Accept the license (if you agree, of course)
    • Select the destination path of your installation. (i use the default C:\Ruby). Below, in the same window
    • Check the box Ruby executables to your PATH (IMPORTANT!) and “Associate .rb and .rbw files with this Ruby installation”
  • Finish the installation

Ruby 1.8 is succesfully installed!

Now it’s time to install Ruby 1.9 .

  • Install Ruby 1.9.1-p378
    • Accept the license
    • Select the destination path of your installation. (i use the default C:\Ruby19). Below, in the same window
    • DO NOT select anything . Leave both check boxs unchecked.
  • Finish the installation

Ruby 1.9 is succesfully installed!

To run Ruby 1.9 binaries you have to use absolute paths. C:\Ruby19\bin\whatever. That’s not so pretty!
To resolve this, i use an easy and smart method found on some discussions at the rubyinstaller google group.

The idea is to put some .bat (windows) scripts in the bin directory of the Ruby 1.8 installation to call internally the Ruby 1.9 binaries. In this way you do not have to add the Ruby 1.9 directory in your PATH env. variable. For my needs this work perfectly good.

In detail:

  • Download Ruby-Bat.rar . Unrar it. Move the five included .bat files (gem19.bat, irb19.bat, rake19.bat, ri19.bat, ruby19.bat) in your ruby-1.8 (not 1.9) installation directory (in my case this is C:\Ruby\bin).
    That’s all.

Open your command prompt and execute :

C:>irb19 
C:>gem19 install rack
C:>ri19 array
C:>rake19 -h

It works!

If you want to know more, open with your favorite editor for example rake19.bat to see what’s inside:

@echo off 
setlocal 
set PATH=C:\Ruby19\bin;%WINDIR%\system32;%WINDIR% 
ruby.exe -S rake %* 
endlocal 

If you need to make a custom ruby(v-1.9) binary just change the filename, substitute `rake` and save it in your ruby-1.8 (not 1.9) installation directory ( C:\Ruby\bin ). Not a perfect solution, but it just works as it should.

Posted in ,  | Tags , , ,  | no comments

Comments

(leave url/email »)

   Preview comment