Installing Ruby

If Ruby was not already installed, this will install it in your system.

_$: sudo apt-get install ruby
_$: ruby -v
ruby 2.1.2p95 (2014-05-08) [x86_64-linux-gnu]

Installing RVM

_$: gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
_$: curl -sSL https://get.rvm.io | bash
_$: source /home/<user>/.rvm/scripts/rvm
_$: rvm list

rvm rubies


# No rvm rubies installed yet. Try 'rvm help install'.

Installing Ruby with RVM

In order to have a custom install of Ruby and the different gems we will use rvm:

_$: rvm install 2.1.2
_$: rvm list

rvm rubies

=* ruby-2.1.2 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

_$: which ruby
/home/<user>/.rvm/rubies/ruby-2.1.2/bin/ruby
_$: which gem
/home/<user>/.rvm/rubies/ruby-2.1.2/bin/gem

RVM scripts

To quickly start in a rvm environment you can create a script in your $HOME directory

/home/<user>/rvm.sh:
--------------------
#!/bin/bash -

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

This way, to start in a new rvm environment you just have to do:

_$: source rvm.sh

Alternatively, you can add the following two lines at the end of your .bashrc file:

/home/<user>/.bashrc:
---------------------
[...]

export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

and you will always have a rvm environment on every new shell you start.