Chronicling My Ruby on Rails Journey

Upgrading Ruby

Posted by: Bob Ngu on: June 23, 2008

I have been silent on this blog for the past few months partly because I am busy with a new blog Ungeek DaPo (data portability technologies) and partly because I haven’t been coding. However I am looking to get back into coding again, so I expect to be more active on this blog once again.

In the few months that I haven’t coded, Rails 2.0 and now 2.1 have been released. My first task is to upgrade my current development (and production) platforms from Ruby 1.8.5 to 1.8.6 (the recommended version for Rails 2.1) and from Rails 1.2.3 to Rails 2.1. I quickly found out that there isn’t a clean way to upgrade Ruby on Windows and preserve the current installed gems.

I came across this thread suggesting a workaround, quoting from the thread

There’s no ruby update AFAIK. You can work around this by renaming c:\ruby to something else, installing ruby, then overwrite C:\ruby\lib\ruby\gems with the old version and call ‘gem update’ to fetch the new versions.

I don’t have much of a choice so I decided to give it a try, wish me luck!

UPDATE (later in the day)
This is not as easy as what’s stated above as the workaround. Once I have a chance to sort things out, I will update this post. In the meantime, here are some of Ruby’s directory structure (courtesy of this post Installing Ruby) that might prove useful to some of you in understanding where Ruby puts things

Ruby Programming Environment

Let’s assume that you have Windows operating system and have installed Ruby in the folder c:\ruby, then the installation creates a number of sub-folders. The folders:

c:\ruby\bin is where the Ruby executables (including ruby and irb) have been installed.
c:\ruby\lib\ruby\1.8 you’ll find program files written in Ruby. These files provide standard library facilities, which you can require from your own programs if you need the functionality they provide.
c:\ruby\lib\ruby\1.8\i386-mswin32 contains architecture-specific extensions and libraries. The files in this directory generally have names ending in .so or .dll (depending on your platform). These files are C-language extensions to Ruby; or, more precisely, they are the binary, runtime-loadable files generated from Ruby’s C-language extension code, compiled into binary form as part of the Ruby installation process.
c:\ruby\lib\ruby\site_ruby folder is where you and\or your system administrator store third-party extensions and libraries. Some of these may be code you yourself write; others are tools you download from other people’s sites and archives of Ruby libraries.
c:\ruby\lib\ruby\gems is the Ruby-Gems packaging system.

UPDATE 6/25/2008
After a couple of days of research, I have decided that the above suggested workaround is a NO-GO for me for the following reasons

  1. There is at least one new gem in Ruby 1.8.6, hpricot, that is not in 1.8.5, so the above workaround would lose hpricot.
  2. c:\ruby\lib\ruby\gems (for the current Ruby 1.8.5) also include all of Rails 1.2.3 gems. Although it seems like gem update would also update Rails (presumably to 2.1), I am not comfortable that something isn’t missing, could be unjustified paranoia but I am not taking any chances.
  3. I use HTree which as it turns out is not installed as a gem, the author didn’t bother to package it as a gem and instead uses Ruby 3rd party extension / library mechanism instead meaning that it is installed under c:\ruby\lib\ruby\site_ruby instead of c:\ruby\lib\ruby\gems. The above workaround does not take this into account.

In the end, I deemed the hackish workaround of upgrading Ruby to be too risky. So I have 2 options currently

  1. Stick with Ruby 1.8.5 and upgrade to Rails 2.1
  2. Blow away the current Ruby 1.8.5, install Ruby 1.8.6, reinstall all the gems and extensions I need, and upgrade to Rails 2.1.

At this point, it doesn’t seem worth the time and effort to upgrade to Ruby 1.8.6 since Rails 2.1 runs on Ruby 1.8.5, so I am going to give option 1 a try. Details on the next post on how it went.

UPDATE 7/1/2008
Best advice yet I received on this matter from Luis Lavena on the Ruby on Rails Windows group

There are several changes from 1.8.5 that will break your gems, no matter how easy we make that process. Also the update to latest rubygems will break projects like mongrel and such that uses pre-compiled extensions (and thus are platform specific gems).

> Is there any chance of building a one-click installer
> that can preserve the current installed gems?

There is no easy way, sorry. First thing first, backup your installation :-)

The new version of the installer we are working on will honor your installed gems and will leave them in place, but right now this installer is not based on that :-(

Jumping from 1.8.5 to 1.8.6 is a difficult step and I suggest you write a list of your gems and manually install them, since there a lot ones that will not work under 1.8.6

UPDATE 5/21/2009
I did finally upgrade ruby 1.8.5 to 1.8.6, see the post here.

2 Responses to "Upgrading Ruby"

[...] Chronicling My Ruby on Rails Journey Sharing my experience in Ruby on Rails development « Upgrading Ruby [...]

Hi Bob,

Since you’re just getting back into RoR … :) we’re trying to build a community Rails site at railsrocket.com. We would love it if you could write for us (even if infrequently / posting the same articles as your blog)! If you’re interested, drop me an email and we can discuss it…

Otherwise, great advice about upgrading!

Leave a Reply