Rails: Installing RoR using RVM

There are many ways to install Ruby on Rails but the current trend is to use a package manager to keep things in order. The best two options for package management are rvm and rbenv. This entry will use RVM.

This article is for anyone interested in using rbenv instead


Step 1 - Install Homebrew

Homebrew is a package manager that simplifies downloading, compiling and installing binary packages.

Installing Homebrew


Step 2 - Install GNU Privacy Guard

gpg is an encryption program used to check the security of the RVM download. Let's use Homebrew to install the package.

brew install gpg

This is a pre-step to intalling RVM

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

Step 3 - Quick shortcut

RVM installs documentation for every gem that Rails depends on, it helps to first disable documentation.

echo "gem: --no-document" >> ~/.gemrc

It helps to create a little progress bar for yourself so that you can determine how long it will take to download.

echo progress-bar >> ~/.curlrc


Step 4 - Install RVM and Ruby and Rails

Let's install both Ruby Version Manager and Ruby on rails using a single line of code.

\curl -sSL https://get.rvm.io | bash -s stable --autolibs=homebrew --rails

Explainer

RVM includes an autolibs[^1] option to identify and install components needed for your operating system. In our case, we aim to enforce homebrew to be our package manager instead of RVM's default enable.

The reason for the \ before curl in order to avoid possible version conflicts.


Step 5 - Double check your work

If you have rvm installed, this should say "rvm is a function"

rvm | head -n 1

Step 6 - Maintenance

Keep your rvm up-to-date.

rvm get stable --autolibs=enable --auto-dotfiles

Troubleshooting

Upgrading RVM

rvm get stable --autolibs=homebrew

Removing RVM entirely

Implode removes all traces of RVM from your system (except for changes such as ~/.bash_profile). You may need to do this if you choose rbenv to manage your ruby packages.

rvm implode

Resources

Tutorials

Footnotes

Rails IDE's