Ruby – Installing RVM

First off you should avoid installing RVM as the root user. Instead, you should install it as a normal user. However at some points while using rvm, you may need to elevate your privilege using sudo (or better yet, rvmsudo). Because of this it is best that you first login as root user, and run “visudo” then add the following line just below the “root” line:

$ usermod -a -G wheel {usernam}

Note: the “wheel” group is a special group that comes in most Linux distros. All members of the “wheel” group automatically gets root privileges. You might need to restart your bash terminal after this for changes to take affect.

After that return to your user and continue with the rest of the steps.

RVM Basics

Here is the main RVM documentation.

Info about curl.

Note it is recommended to install rvm as non-root user.

gpg --keyserver hkp:// --recv-keys D39DC0E3

The output from this is:

[sher@puppetmaster ~]$ gpg --keyserver hkp:// --recv-keys D39DC0E3
gpg: requesting key D39DC0E3 from hkp server
gpg: key D39DC0E3: public key "Michal Papis (RVM signing) " imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
[sher@puppetmaster ~]$

Then run:

curl -sSL | bash -s stable

Note: you might need to install curl via yum before you can run the above command.

Let’s breakdown what this command is doing by first looking at the curl part. In this case, the curl command basically downloads this shell script. Which is also available on github as is called the rvm-installer.

Here’s what the curl options means:

L: this stands for (L)ocation
s: This means run in (s)ilent mode. This is optional and it’s best to omit this so that you can see what’s going on.
S: This means (S)how errors. This is optional, but it is best to leave this in so that you can see any errors/warnings.

If you review the script, you’ll find that it requires a positional parameter, one of the values that this parameter can take is “stable”, which according to the shell script will install the latest version of rvm.

Since curl just retrieves the script, you can easily just pipe it to a file.

However in the above case we have piped it to bash to run it. We also instructed bash (via the bash -s option) to pass the first parameter as “stable”.

Therefore when you run this, you get:

[sher@puppetmaster ~]$ curl -SL | bash -s stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22817  100 22817    0     0  18550      0  0:00:01  0:00:01 --:--:--  293k

Installing RVM to /home/sher/.rvm/
    Adding rvm PATH line to /home/sher/.profile /home/sher/.mkshrc /home/sher/.bashrc /home/sher/.zshrc.
    Adding rvm loading line to /home/sher/.profile /home/sher/.bash_profile /home/sher/.zlogin.
Installation of RVM in /home/sher/.rvm/ is almost complete:

  * To start using RVM you need to run `source /home/sher/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

# sher,
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
# ~Wayne, Michal & team.

In case of problems: and

  * WARNING: You have '~/.profile' file, you might want to load it,
    to do that add the following line to '/home/sher/.bash_profile':

      source ~/.profile

[sher@puppetmaster ~]$

Then follow the advise:

[sher@puppetmaster ~]$ source ~/.profile

Notice that running the above command resulted in the rvm getting installed under the user’s home directory, in a folder called “.rvm”:

[sher@puppetmaster ~]$ pwd
[sher@puppetmaster ~]$ which rvm
[sher@puppetmaster ~]$

Now to confirm that rvm is now installed and working, you can now use the rvm command:

[sher@puppetmaster ~]$ rvm --version
rvm 1.26.9 (master) by Wayne E. Seguin , Michal Papis  []
[sher@puppetmaster ~]$

However at this point nothing else has changed i.e. no new gems have been installed (gem list), the gem environment is unchanged (gem environment), and ruby version is unchanged (ruby –version)

You can also access the help info:

rvm help

Now, rvm may require other packages to be installed (using yum along with rvmsudo). To check this, run rvm requirements:

[sher@puppetmaster ~]$ rvm requirements
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: libyaml-devel, autoconf, gcc-c++, readline-devel, zlib-devel, libffi-devel, openssl-devel, automake, libtool, bison, sqlite-devel..sher password required for 'yum install -y libyaml-devel autoconf gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel automake libtool bison sqlite-devel':

Here you’ll get a password prompt. In which case exit this and run the above yum command (using rvmsudo). after that rerun rvm requirements to confirm everything is in place.

However at this point, still nothing else has changed i.e. no new gems have been installed (gem list), the gem environment is unchanged (gem environment), and ruby version is unchanged (ruby –version) (do not use sudo)

See also: