All notes
Rvm

Quick Start

Installation


# Install mpapis (the author) public key
# https://github.com/rvm/rvm/issues/3110
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

# Installing the stable release version:
\curl -sSL https://get.rvm.io | bash -s stable


##########
# wcfNote:

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
rvm use [email protected]

##########

# 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 [email protected]

# Establish two enviroments for two rails versions:
rvm gemset create rails410 rails320
rvm [email protected]
gem install rails -v 4.1.0
rvm [email protected]
gem install rails -v 3.2.0
rvm [email protected] ; rails --version
# Rails 4.1.0
rvm [email protected] ; rails --version
# Rails 3.2.0

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

rvm use [email protected]$NAME

ruby-gemset, ruby-version, rvmrc



# http://stackoverflow.com/questions/21142065/create-ruby-version-and-ruby-gemset-with-rvm
# Create .ruby-version and .ruby-gemset.
rvm --create --ruby-version [email protected]

# If .ruby-gemset is not working, use .rvmrc instead.
# To generate one:
rvm --rvmrc use [email protected]

default, system

rvm.io: 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

Commands

autolibs

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

requirements

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

FAQ

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


# http://stackoverflow.com/questions/19061774/cannot-load-such-file-bundler-setup-loaderror
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.