Blog

Manage Rubies with rbenv

A lot of Quick Left-ers have started using rbenv to control Ruby versions; most have been moving away from rvm. If you're ready to make the switch, go ahead and skip ahead to the Getting Started guide. Still not convinced, read on…

Why would I do this?

We all love rvm. In its own right it's an achievement in bash-scripting, but some still yearn for something a bit more intuitive and less intrusive.

rbenv is a more UNIXish way to manage versions of Ruby on a per-project basis. rbenv is simply an utility to switch versions of Ruby on the fly. It doesn't overwrite commands like cd, and doesn't require gemset management.
On the same note, it doesn't install Rubies for you, but we'll make sure we still have an easy way to do this in the following guide.

Getting Started

Up front, a couple notes:

This guide assumes Homebrew is installed.
Remove rvm first! To remove rvm completely (thanks, Wayne), run: rvm implode

1. Install rbenv:

$ brew install rbenv

2. Install ruby-build:

$ brew install ruby-build

This allows us to install different Rubies (rbenv doesn't have an install command).

System configuration:

To ignore the version files rbenv makes add this to your global gitignore (maybe in ~/.gitconfig_global)

.rbenv-version

To ignore your locally bundled gems add this to ~/.bundle/config:

---
BUNDLE_PATH: vendor/bundle

finally, edit bash profile (probably ~/.bash_profile), so that rbenv is instantiated with your shell

eval "$(rbenv init -)"

–restart your shell–

So, how do I use it?

Well, your Rubies are gone, and your gemsets with them. So let's install a Ruby and get a project working again.

That's it. Next steps? Maybe getting the local version of Ruby in our prompt?