Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

RVM Cheat Sheet

Jimmy Dee edited this page Sep 2, 2017 · 8 revisions

The Ruby environment is notoriously error prone. This has been known to cause problems for some Fastlane actions when using the system Ruby on OS X in particular. (Apple ships Ruby 2.0, which was deprecated in February 2016.) It is recommended to use RVM, rbenv or chruby to manage your Ruby environment and work with a more current Ruby (e.g. 2.4.1).

This is a list of common commands used to install, maintain and work with RVM. Some examples are specific to OS X. Most are universal.

See https://rvm.io for more information on RVM.

Prerequisite

A functional development environment is required, with standard compilers and other build tools. On OS X, this means you have to install Xcode and the associated command-line build tools.

Setup GPG key (required if GPG is installed)

This is a one-time preparation step. RVM must verify its signature if GPG is available. Skip this if which gpg2 returns nothing on a Mac.

OS X:

gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Install RVM

\curl -sSL https://get.rvm.io | bash

Note the initial backslash, recommended to avoid shell aliases (but not necessarily required). This command modifies your shell initialization files. RVM is a shell extension. These modifications allow it to be automatically loaded. If it's not automatically loaded (in a script, e.g.), load it with:

. ~/.rvm/scripts/rvm

Setup autolibs (optional)

RVM will install any required native dependencies when installing Ruby. It may prompt for a sudo password if it must make any updates. Some operating systems (e.g. OS X) offer different methods of obtaining native dependencies. By default, on OS X, RVM will use Homebrew to install dependencies if it is available. If you would rather use MacPorts, e.g.,:

rvm autolibs macports

See https://rvm.io/rvm/autolibs for a full list of autolibs options.

Update RVM

rvm get master

or

rvm get head

These commands are the same.

Reload RVM

rvm reload

RVM automatically reloads when updated. Use this command in other shell windows after updating.

Show all available Rubies

rvm list known

Install a specific Ruby

rvm install ruby-2.4.1

or

rvm install 2.4.1

List installed Rubies

[jdee@Jimmy-Dees-MacBookPro ~]$ rvm list

rvm rubies

   ruby-2.0.0-p648 [ x86_64 ]
   ruby-2.2.0 [ x86_64 ]
   ruby-2.2.6 [ x86_64 ]
   ruby-2.3.3 [ x86_64 ]
   ruby-2.3.4 [ x86_64 ]
   ruby-2.4.0 [ x86_64 ]
 * ruby-2.4.1 [ x86_64 ]

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

Choose the default Ruby

rvm use 2.4.1 --default

Choose the current Ruby to use

rvm use 2.4.1
rvm use ruby-2.4.1
rvm use ruby # Uses the latest available release, which may have to be installed first
rvm use default # Uses whatever you set as the default

Use the system Ruby

rvm use system
rvm system

Uninstall a Ruby

rvm uninstall 2.4.1 # Retains sources
rvm remove 2.4.1 # Removes sources

Remove RVM entirely

rvm implode

Using RubyGems and the Bundler

RVM installs everything by default to a writable location under ~/.rvm. Do not use sudo when installing gems. It is not necessary and can lead to permission problems if used.

Installing gems

gem install bundler

Now the bundle command is available in your path under ~/.rvm. This will also work, e.g., with the fastlane gem: gem install fastlane, and the fastlane command is in your PATH under ~/.rvm. This will usually work quite well, but you'll be better off using bundle exec when running Fastlane with plugins.

Updating gems

gem update # Updates all installed gems
gem update bundler # Updates the bundler gem.
gem install bundler # Updates a gem that's already installed

Updating RubyGems

gem update --system

This updates the gem command itself. Again, don't use sudo here.