Installed Ruby 1.9.1 but ruby -v gives 1.8.7

I’m trying to update Ruby on my Ubuntu system. What should I do after
installing Ruby 1.9.1?

Since ruby -v gives 1.8.7 I’m assuming there are probably some
configuration changes I need to do. But I have no idea what.

I’m very new at Linux as well.

try “ruby1.9.1 -v”
and to run code under 1.9.1 - “ruby1.9.1 foo.rb”

1.8.7 is still your system default ruby. there may well be other ways,
but i have used both rvm and update-alternatives to switch between
multiple versions of ruby. if you’ve installed both versions from the
ubuntu repository, update-alternatives should work well for you…

http://www.veebsbraindump.com/2010/08/supporting-multiple-ruby-versions-on-ubuntu-10-04-lucid/

  • j

From the command line, type

$ which ruby

/usr/bin/ruby (on my machine)

Go to the directory specified and type

$ ls ruby*

You’ll probably see ‘ruby1.8’, ‘ruby1.9.1’ and ‘ruby’ plain side by side
in the directory. The last one, ‘ruby’, is most likely a link to
ruby1.8. Try to delete the link and remake it, pointing to ruby1.9.1
instead.

% sudo update-alternatives --config ruby

will allow selections of ruby version.