Running Ruby 1.9.1 with RVM on Ubuntu karmic

It’s finally time to try out things with Ruby 1.9 – people start complaining that my libs don’t run with 1.9. Sorry for that. I’m still sticking to “Never touch a running system!”, so why should I use Ruby 1.9 when 1.8 works great?

RVM

First I discovered rvm which is a great tool for hosting different Ruby versions in your shell and switching environments on the fly.

That’s

> sudo gem install rvm

Now go and install Ruby 1.9.1 (couldn’t get 1.9.2 working)

> rvm install 1.9.1

This will install Ruby 1.9.1 in your home directory, which is awesomely cool.

Switching to the new ruby/gems is nothing more than

> rvm use 1.9.1

Running Rails

Things start getting shitty now. When trying to run Rails with ruby 1.9 I got something

no such file to load -- openssl

rvm explains to install the package openssl. That doesn’t work for me

$ rvm package install openssl
Package 'openssl' is unknown.
Usage: 'rvm package {install,uninstall} {openssl,zlib,readline,iconv,ncurses}'

which is… strange.


Note: Wayne fixed that in the rvm release 0.1.24 – so the rest of this article is useless. Thanks, cowboy!


Following the great directions here didn’t help either, although it’s a good post.

At some point make failed with

error: ruby/io.h: No such file or directory

The solution

I finally ended up fixing it with

$ sudo apt-get install libopenssl-ruby1.9.1
$ cp /usr/lib/ruby/1.9.1/i486-linux/openssl.so ~/.rvm/rubies/ruby-1.9.1-p378/lib/ruby/1.9.1/i686-linux/
$ cp -R /usr/lib/ruby/1.9.1/openssl* ~/.rvm/rubies/ruby-1.9.1-p378/lib/ruby/1.9.1/

and the shit’s working.

Installing gems

rvm provides some decent way to install gems, it works like

$ rvm 1.9.2 gem install cells --no-ri --no-rdoc

When running ruby 1.8.7 be sure to install sqlite3-ruby, not sqlite3. The latter version is only for 1.9 and will throw arbitrary

NameError: uninitialized constant Encoding

Hope that helps!

Advertisements

2 thoughts on “Running Ruby 1.9.1 with RVM on Ubuntu karmic

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s