I have Ruby versions 1.8.7 and 1.9.1 on Ubuntu.

How do I get the system to register Ruby 1.9.1 when using ruby -v?

ruby is at /usr/bin/ruby
ruby1.9.1 is at /usr/bin/ruby1.9.1

Also, can someone recommend a free text editor for Ubuntu?


alias ruby='ruby1.9' or the like.


find ruby in your path. Either change your PATH variable to direct through the Ruby 1.9 executable (assuming different directories) or create a symbolic link of "ruby" to the versiuon you want.

The alias solution above will work, but only when your envuironment 8is sourced into the shell. The link method works anywhere in a UNIX-like system.

Lert's assume you have the executables in /usr/bin. This means that there is something like


What you need is to

  1. rename /usr/bin/ruby as /usr/bin/ruby1.8.7
  2. Write a short shell script selectRuby that takes an argument, and
    • if it's 8, execute ln -s /usr/bin/ruby1.8.7 /usr/bin/ruby
    • if 9, execute ln -s /usr/bin/ruby1,9 /usr/bin/ruby

Ideally, you might want to have a default that sets one version or the other.

This script would, by necessity, have to be run through sudo. If you don't want to, or cant, then set up your own bin directory at, say, ~/bin and have a script that links ruby to /usr/bin/ruby or /usr/bin/ruby1.9 as desired. Make sure your bin is before the more global bins in your path and you'll be set.

Charlie Martin
i'm a complete newbie, please show how, thanks.
IN fact rvm more or less does what I suggested. I didn't realize there was a tool.Okay,. your profile is a file named `.profile` in your home directory. Use the `ls -a` commands, and you should see it. Simply type that in verbatim at the end of the file, or if you don't have a .profile, create it and add that line.What it really says, btw, is essentially "test if $HOME/.rvm/scipts/rvm exists and has contents, and if so, read that file into this shell as if it had been typed at the commend line.
Charlie Martin
You might have a look at sopme of the bash tutorials, like this one: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Charlie Martin
+3  A: 

I would consider using rvm to manage multiple versions of Ruby. At first I was a bit skeptical about it, but once installed and configured, I found it works perfectly. I can now flip between 1.8.7, 1.9.2, and JRuby-1.5.1 and the paths change automatically.

Mark Thomas
I'd edit your .bashrc. From the terminal, "gksudo gedit ~/.bashrc" and add the line at the end.
Mark Thomas

I am assuming by text editor, he means a text editor for Ruby. There are a ton of options: Kate, Komodo, Vim, Emacs, etc. However for Ruby development, I would recommend Redcar. Its cross platform compatible, open source, supports textmate bundles, and is written entirely in Ruby so its easy to extend with plugins.

+2  A: 

An ubuntu-like way could also be using "update-alternatives" as described here
Using RVM might save you a headache or two though :)

As for the texteditor: just use gedit and enable a few of its plugins

Marc Seeger

Hi Roger,

You can do that by using a symbolic link

ln -s /usr/bin/ruby1.9.1 /usr/bin/ruby




I found out how to do it on it a Mac, probably the same for ubuntu: