Upgrading From Ruby 1.9.1 to Ruby 1.9.2

computer 24 September 2010 | 9 Comments

I’ve spent half the day so far inbeded in the furious stressful upgrade process of a handful of Ubuntu Linux 10.04 and Mac OS X Snow Leopard systems from Ruby 1.9.1 to Ruby 1.9.2. I haven’t even gotten to the Rails 3.0.0 stuff yet: just the baseline Ruby installation. I’ve gone through the upgrade process on both types of systems so far and the base issues have been the same. Here’s a common issue that many people are running into:

preston$ gem1.9

/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:68:in `installed_spec_directories': undefined method `path’ for Gem:Module (NoMethodError)
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:58:in `from_installed_gems’
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems.rb:883:in `source_index’
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/gem_path_searcher.rb:81:in `init_gemspecs’
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/gem_path_searcher.rb:13:in `initialize’
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems.rb:841:in `new’
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems.rb:841:in `block in searcher’
from <internal:prelude>:10:in `synchronize’
<…and so on…>

Assuming you’re upgrading from a previous Ruby installation, note that the “site_ruby” directories are no longer used, and will eff up your 1.9.2 installation if you fail to delete them after the install. On OS X, run:

sudo rm -rf /opt/local/lib/ruby1.9/site_ruby/

On Ubuntu Linux 10.04, run:

rm -rf /usr/local/lib/ruby/site_ruby/

…to correct this issue. All note that you may see errors such as this:

root@li92-132:~# rake –version

/usr/local/lib/ruby/1.9.1/rubygems.rb:340:in `bin_path': can’t find executable rake for rake-0.8.7 (Gem::Exception)

from /usr/local/bin/rake:19:in `<main>’

…despite have a rake gem installed. Apparently 1.9.2 comes with a version of rake internally, but is unable to find it for some reason relating to the rake.gemspec file. Remove the file to fix this issue. On Ubuntu Linux 10.04, run:
rm /usr/local/lib/ruby/gems/1.9.1/specifications/rake.gemspec
Notice the “1.9.1” path of the PATH. Yeah.. it’s weird. But for compatibility reasons your 1.9.2 installation will continue to use a path with 1.9.1. To quote the Ruby 1.9.2 FAQ page:
The standard library is installed in /usr/local/lib/ruby/1.9.1
This version number is “library compatibility version”. Ruby 1.9.2 is mostly compatible with the 1.9.1, so its library is installed in the directory.
I’m sure there’s a wonderful technical reason for this, but it’s still misleading and confusing as hell. I ended up manually deleting a bunch of stuff I shouldn’t have because I thought I was innocently “cleaning up” after the old version. Whatever. Additional suggestions:
  • Just to keep things clean, you may also want to remove your old Ruby 1.8.x builds. (I recommend doing so unless you have older apps that haven’t moved to 1.9.x yet.)
  • Phusion Passenger seems to work fine on Ubuntu 10.04 with the latest version of Apache 2 as of this writing, though don’t forget to recompile, reinstall, reconfigure and restart apache2 when you do so.
  • Check if you still need rack v1.0.1 installed (for older Rails app) before nuking everything. :(
I need a beer!

Tagged in , , , , , , , , , , , , ,

9 Responses on “Upgrading From Ruby 1.9.1 to Ruby 1.9.2”

  1. Markus says:

    Many thanks, had the bin_path issue with 1.9.2 p0 and head on my rvm installation, thus I deleted the following files:

    ~/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/specifications/rake.gemspec
    ~/.rvm/rubies/ruby-1.9.2-head/lib/ruby/gems/1.9.1/specifications/rake.gemspec

    thanks!

  2. Austin says:

    RVM may have its own issues, but I would definitely say you should check it out if you aren’t using it already. It makes sandboxing ruby installs and gemsets very straightforward.

    Austin

  3. admin says:

    I agree it’s a cool tool… I just like to keep my work system super clean and have a minimum amount of development tools installed. I’m doing stuff in Java, Ruby, C/C++ and Objective-C right now so anything I can remove (such as old Ruby versions) I try to take advantage of. :(

  4. jacob says:

    Thank you so much for this! You saved me many hours.

  5. admin says:

    No problem. :)

  6. Matt says:

    It works! Is it too much to say that you’re currently my hero? I’ve been struggling with this all day.

  7. admin says:

    Glad I could help! :)

  8. Jim says:

    Nice one fella. Don’t know what I did but all of a sudden last night my Rake/Rubygems broke. Had me scratching my head until I found this. Cheers!

  9. Chad Arimura says:

    thanks man…. good stuff.

Leave a Reply