The magical journey of switching from rvm to rbenv

At work, our servers are using rbenv to manage the ruby version our apps use but until today I was using rvm in my machine. According to its author, rbenv is supposed to be more lightweight and less invasive than its counterpart rvm. Also, Stephenson is inspired by the Unix philosophy "write programs that do one thing and do it well".

Because of that, instead of being a do-it-all piece of software like rvm, rbenv relies on plugins to allow its users to customize its functionality based on their needs.

Removing rvm and installing rbenv

These steps asume you are using Mac OS X and homebrew.

Step 1: Get rid of rvm by running rvm implode.
Step 2: Check and update your homebrew installation with brew update and brew install rbenv.
Step 3: Install rbenv and ruby-build by issuing brew install rbenv ruby-build.
Step 4: Remove or comment out all references ([[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm") to rvm in your .bash_profile, .zprofile or the config file of whatever unix shell you're using.
Step 5: Add the required rbenv initializer to your shell configuration file: eval "$(rbenv init -)"

You can also install different rbenv plugins that can help you accomplish specific tasks, like:

  • rbenv-binstubs if you want to avoid issuing bundle exec each time you want to run a project-specific environment.
  • rbenv-gem-rehash so you don't have to run rbenv rehash to make your environment aware of a newly installed gem.

Wait...but what about gemsets?!

If, like me, you like having separate sets of gems on a per-project basis, you can make use of the rbenv-gemset plugin.

There's also a few other options, like just using Bundler and its stubs or a bash script like oh my gems!


I was quite happy with rvm but I thought it would be a good idea to use the same tools our servers use in order to minimize issues related to inconsistencies between the development and production environments. With this setup you should have at least the very same basic functionality rvm provides.

References and related reading

Author image
Santiago, Chile Website
Web developer for the last 4 or so years, Mauricio tries hard to stand out and go beyond his limits, which usually doesn't work very well, but when it does it feels awesome!