Terry : RVM

RVM - Ruby Version Manager

Installing RVM

Unless doing guided install you should read all sub-sections under the RVM Section.

Install RVM with ruby

# curl
curl -L https://get.rvm.io | bash -s stable
curl -L https://get.rvm.io | bash -s stable --ruby
# wget
wget -q https://get.rvm.io -O - | bash -s stable
wget -q https://get.rvm.io -O - | bash -s stable --ruby

NOTE: curl by default outputs to stdout, for wget use -O - or just -O- which looks great! For bash, -s makes it read from stdin.

Additionally with rails

curl -L https://get.rvm.io | bash -s stable --rails

Or with rubinius, rails and puma

curl -L https://get.rvm.io | bash -s stable --ruby=rbx --gems=rails,puma

Finally, to install without the "rubygems-bundler" or "rvm" gems

curl -L https://get.rvm.io | bash -s stable --without-gems="rvm rubygems-bundler"

Point to be noted is, there is a backslash before curl. This prevents misbehaving if you have aliased it with configuration in your ~/.curlrc file.

If you're an existing RVM user and you don't want RVM to attempt to setup your shell to load RVM, you can opt out of this at install time by exporting rvm_ignore_dotfiles=yes, or opt out permanatly by setting this in your rvmrc.

You can also:

Installation explained

There are three different ways to install and configure RVM.

  1. Single-User installations (recommended) - For an isolated install within a user's $HOME, not for root.
    Single-User Install Location => ~/.rvm/
    NOTE: If the install script is run as a standard, non-root user, RVM will install into the current users's home directory.

  2. Multi-User installations - For server administrators - For server administrators - For an installation usable by all users on the system - Please note that Single-User supercedes Multi-User. This also used to be called the System-Wide Install. Using this type of installation without knowledge how umask works is a big security risk.
    Multi-User Install Location => /usr/local/rvm
  3. Mixed mode installations - For an installation usable by all users on the system - with isolated rubies/gemsets within a user's $HOME. Installation instructions are exactly the same as for Multi-User installations, the difference is in users environment.

get.rvm.io is a redirect to https://github.com/wayneeseguin/rvm/blob/master/binscripts/rvm-installer You could also use full path for the installer

curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable

Install stable or development

Installing the stable release version

curl -L https://get.rvm.io | bash -s stable

To get the latest development state

curl -L https://get.rvm.io | bash

For a Multi-User install you would execute the following

curl -L https://get.rvm.io | sudo bash -s stable

Installing a specific version

curl -L https://get.rvm.io | bash -s -- --version latest
curl -L https://get.rvm.io | bash -s -- --branch [owner/][repo]

Prefix the 'bash' portion with 'sudo', of course, if you wish to apply this to a Multi_user Install. Please feel free to check out our upgrading docs for more details on branch format.

Installing on Ubuntu 12.04

Output

terry@ubuntu:/bea$ curl -L https://get.rvm.io | bash -s stable --ruby
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   185  100   185    0     0    155      0  0:00:01  0:00:01 --:--:--   174
100 10472  100 10472    0     0   3841      0  0:00:02  0:00:02 --:--:--  6803
Please read and follow further instructions.
Press ENTER to continue.
Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   131  100   131    0     0    101      0  0:00:01  0:00:01 --:--:--   108
100 1243k  100 1243k    0     0   187k      0  0:00:06  0:00:06 --:--:--  308k
Installing RVM to /home/terry/.rvm/
    Adding rvm PATH line to /home/terry/.bashrc /home/terry/.zshrc.
    Adding rvm loading line to /home/terry/.bash_profile /home/terry/.zprofile.
# RVM:  Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.io/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Cheatsheet: http://cheat.errtheblog.com/s/rvm/
# Screencast: http://screencasts.org/episodes/how-to-use-rvm
# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'
Installation of RVM in /home/terry/.rvm/ is almost complete:
  * To start using RVM you need to run `source /home/terry/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
# Terry Wang,
#
#   Thank you for using RVM!
#   I sincerely hope that RVM helps to make your life easier and
#   more enjoyable!!!
#
# ~Wayne

rvm 1.17.3 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
https://rvm.io/binaries/ubuntu/12.04/x86_64/ruby-1.9.3-p327.tar.bz2 - #configure
ruby-1.9.3-p327 - #download
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 11.4M  100 11.4M    0     0   449k      0  0:00:26  0:00:26 --:--:--  489k
ruby-1.9.3-p327 - #extract
ruby-1.9.3-p327 - #validate
ruby-1.9.3-p327 - #setup
Saving wrappers to '/home/terry/.rvm/bin'.
ruby-1.9.3-p327 - #importing default gemsets (/home/terry/.rvm/gemsets/), this may take time ...
Creating alias default for ruby-1.9.3-p327.
Recording alias default for ruby-1.9.3-p327.
Creating default links/files
Saving wrappers to '/home/terry/.rvm/bin'.
  * To start using RVM you need to run `source /home/terry/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

Remember to source ~/.rvm/scripts/rvm

Load RVM into your shell sessions as a function

Single-User

The rvm function will be automatically configured for every user on the system if you install as single user. Read the output of installer to check which files were modified.

Multi-User

The rvm function will be automatically configured for every user on the system if you install with sudo. This is accomplished by loading /etc/profile.d/rvm.sh on login. Most Linux distributions default to parsing /etc/profile which contains the logic to load all files residing in the /etc/profile.d/ directory. Once you have added the users you want to be able to use RVM to the rvm grou p, those users MUST log out and back in to gain rvm group membership because group memberships are only evaluated by the operating system at initial login time. Zsh not always sources /etc/profile so you might need to add this in /etc/**/zprofile:

source /etc/profile

Reload shell configuration & test

Close out your current shell or terminal session and open a new one (preferred). You may load RVM with the following command

source ~/.rvm/scripts/rvm

If installation and configuration were successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output 'rvm is a function' as shown below.

$type rvm | head -n 1
rvm is a function

Finally, see if there are any dependency requirements for your operating system by running

terry@ubuntu:/bea$ rvm requirements
Requirements for Linux "Ubuntu 12.04.1 LTS"
NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
             This is the *original* / standard Ruby Language Interpreter
      'ree'  represents Ruby Enterprise Edition
      'rbx'  represents Rubinius
bash >= 4.1 required
curl is required
git is required (>= 1.7 for ruby-head)
patch is required (for 1.8 rubies and some ruby-head's).
To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),
then you must install and use rvm 1.8.7 first.
Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
  ruby: /usr/bin/apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
# For JRuby, install the following:
  jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
  jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk
# For IronRuby, install the following:
  ironruby: /usr/bin/apt-get install curl mono-2.0-devel
# For Opal, install the following:
  opal: /usr/bin/apt-get install nodejs npm

NOTE: Whenever you upgrade RVM in the future, you should always run 'rvm notes' and 'rvm requirements' as this is usually where you will find details on any major changes and/or additional requirements to ensure your installation stays working. Also, you should also run the above command on any fresh installs. This is where all your additionals will be noted making it an extremely important stop on your way to RVM bliss!

Congratulations! You have successfully installed RVM.

RVM in action

Display a list of all "known" rubies. NOTE: rvm list == rvm list rubies

$ rvm list
rvm rubies
=* ruby-1.9.3-p327 [ x86_64 ]
   ruby-2.0.0-preview2 [ x86_64 ]
# => - current
# =* - current && default
#  * - default

Install a version of Ruby, for example 2.0.0-preview2

$ rvm install 2.0.0-preview2
No binary rubies available for: downloads/ruby-2.0.0-preview2.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Fetching yaml-0.1.4.tar.gz to /home/terry/.rvm/archives
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  460k  100  460k    0     0   150k      0  0:00:03  0:00:03 --:--:--  162k
Extracting yaml to /home/terry/.rvm/src/yaml-0.1.4
Configuring yaml in /home/terry/.rvm/src/yaml-0.1.4.
Compiling yaml in /home/terry/.rvm/src/yaml-0.1.4.
Installing yaml to /home/terry/.rvm/usr
Installing Ruby from source to: /home/terry/.rvm/rubies/ruby-2.0.0-preview2, this may take a while depending on your cpu(s)...
ruby-2.0.0-preview2 - #downloading ruby-2.0.0-preview2, this may take a while depending on your connection...
ruby-2.0.0-preview2 - #extracting ruby-2.0.0-preview2 to /home/terry/.rvm/src/ruby-2.0.0-preview2
ruby-2.0.0-preview2 - #extracted to /home/terry/.rvm/src/ruby-2.0.0-preview2
ruby-2.0.0-preview2 - #configuring
ruby-2.0.0-preview2 - #compiling
ruby-2.0.0-preview2 - #installing 
Retrieving rubygems-1.8.24
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  371k  100  371k    0     0  48928      0  0:00:07  0:00:07 --:--:--  100k
Extracting rubygems-1.8.24 ...
Removing old Rubygems files...
Installing rubygems-1.8.24 for ruby-2.0.0-preview2 ...
Installation of rubygems completed successfully.
Saving wrappers to '/home/terry/.rvm/bin'.
ruby-2.0.0-preview2 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-2.0.0-preview2 - #importing default gemsets (/home/terry/.rvm/gemsets/), this may take time ...
Install of ruby-2.0.0-preview2 - #complete 

Use newly installed Ruby

$ rvm use 2.0.0-preview2
Using /home/terry/.rvm/gems/ruby-2.0.0-preview2

Check version

$ ruby -v
ruby 2.0.0dev (2012-12-01 trunk 38126) [x86_64-linux]
$ which ruby
/home/terry/.rvm/rubies/ruby-2.0.0-preview2/bin/ruby

Optionally, you can set a version of Ruby to use as the default for new shells. Note that this overrides the 'system' ruby

rvm use 1.9.3 --default

Update rubygems

Update rubygems for selected ruby

$ rvm rubygems latest
Removing old Rubygems files...
Installing rubygems-1.8.24 for ruby-1.9.3-p327 ...
Installation of rubygems completed successfully.
$ gem -v
1.8.24

Uninstall

To uninstall RVM

method 1

rm -rf ~/.rvm and clean up your bash/zsh profiles (if you source $rvm_path/scripts/rvm)

rm -rf ~/.rvm

method 2

rvm implode => this removes the rvm installation completely. This removes the rvm installation completely. This means everything in $rvm_path (~/.rvm). This does not touch your profiles, however. You MUST manually clean up your profiles and remove the lines which source $rvm_path/scripts/rvm.

everything in $rvm_path (~/.rvm).

rvm implode

NOTE: DO NOT forget to clean up your profiles in both cases.

Reference

https://rvm.io/

RVM Cheat Sheet