If you plan on doing a lot of development in ruby, then
rvm (ruby version manager) is the way to use lots of different ruby versions and gems. If you just want to run ruby, you should use your system's package manager.
This is a condensed version of
Chistopher Irish's excellent write-up
(leading
$ is the bash prompt)
$ sudo apt-get install curl git-core ruby
$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
If you haven't already replaced your .bashrc, you probably have a line in there like this:
[ -z "$PS1" ] && return
Replace that line with:
if [[ -n "$PS1" ]]; then
Then, add this to the last line of the .bashrc file (however, you can leave off that very final, dangling 'fi' if you did NOT have a return statement that you replaced earlier).
if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi
fi
There are going to be prerequisites to installing most ruby's. Use the command
rvm notes to discover those dependencies for your system.
Okay, we'll grab some prerequisites for compiling 1.9.2:
$ sudo aptitude install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf
Now, we can list the ruby versions we can install, install 1.9.2, and set it as default.
rvm list known # see which ruby versions we could install
rvm install 1.9.2-head
rvm --default 1.9.2-head # make ruby 1.9.2 our default