All notes

Quick Start


RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.


# Install mpapis (the author) public key
gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

# Installing the stable release version:
\curl -sSL | bash -s stable


#---------- Gemsets

rvm install 2.2.0 -C --with-jemalloc

# Must use login shell.
bash --login

# Switch to ruby-2.2.0.
rvm 2.2.0

rvm gemset create me
#gemset created /Users/me/.rvm/gems/ruby-2.2.6@me

rvm use 2.2.0@me

rvm list # To check
rvm current

# Or directly
rvm use 2.2.0@me --create

rvm gemset use default
# OR:
rvm use @default

# You can also specify a *default* gemset for a given ruby interpreter
rvm use 2.1.1@teddy --default

#----- Delete
rvm gemset delete teddy

#----- List
rvm gemset use teddy
rvm gemset name
# teddy

rvm gemdir
# /Users/rys/.rvm/gems/2.1.1@teddy

rvm gemset list

# To list all named gemsets for all interpreters
rvm gemset list_all


# List all ruby versions.
rvm list
# Switch to ruby version 2.1.3
rvm 2.1.3
# If there is none, you have to install one first:
rvm install ruby-2.1.3

# List all gemsets.
rvm gemset list
rvm current

# Re-add RVM to your dotfiles:
rvm get stable --auto-dotfiles
# To fix temporarily in this shell session, run:
rvm use ruby-2.1.3@projName

# Establish two enviroments for two rails versions:
rvm gemset create rails410 rails320
rvm 2.1.1@rails410
gem install rails -v 4.1.0
rvm 2.1.1@rails320
gem install rails -v 3.2.0
rvm 2.1.1@rails410 ; rails --version
# Rails 4.1.0
rvm 2.1.1@rails320 ; rails --version
# Rails 3.2.0

# Show the path
rvm env
# Show gem dir path
rvm env gemdir

rvm use 2.1.3@$NAME

ruby-gemset, ruby-version, rvmrc

# Create .ruby-version and .ruby-gemset.
rvm --create --ruby-version ruby-2.1.3@me

# If .ruby-gemset is not working, use .rvmrc instead.
# To generate one:
rvm --rvmrc use 2.1.3@me

default, system default.

rvm --default use 2.1.1
# The next time you open a window Ruby 2.1.1 will be the selected ruby.

# To switch back to your system ruby
rvm use system
which ruby # It's now system ruby.
# /usr/bin/ruby

# To switch at any time to the ruby you have selected as default:
rvm default
# Using /home/dev/.rvm/gems/ruby-2.1.1

# To set the "system" ruby as default, you reset RVM's defaults as follows.
rvm reset

# You can try using the alias action instead:
rvm alias create default 2.1.1



Autolibs is a feature built into RVM to allow you to automatically install dependencies on your system. autolibs.


requirements: installs additional OS specific dependencies/requirements for building various rubies (by default run by `install`).


RVM env is not working after switching termials

SO: rvm when open new terminal.

# Set the default version:
rvm --default use 1.9.3

# This setting usually exists in ~/.bash_profile, but not ~/.bashrc.
# Add it to rc script, e.g. ~/.bashrc.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

Cannot load such file -- bundler/setup

gem install bundler

Why login bash is required?

The RVM config line ( -s "$HOME/.rvm ...") likely located is in .profile, which is only read when your bash is on login-shell mode. SO: why RVM needs login shell.