Ruby installations on steroids

Firstly, I highly recommend using Rbenv for managing your ruby installations. It’s very custimizable and less intrusive than RVM. To get started, install it via Homebrew

brew install rbenv ruby-build

or explore alternative ways here.

Rbenv adheres to the unix philosophy of doing one thing well, which is managing Ruby installations. The responsibility of actually installing rubies is delegated to ruby-build.

Automatic rehashing new gem binaries

When installing gems with binaries you need to run rbend rehash for your shell to know about them. The rbenv-gem-rehash plug-in alleviates this by automatically rehashing newly installed binaries.

Install the plug-in and you’re all set:

git clone ~/.rbenv/plugins/rbenv-gem-rehash

Add default gems for new rubies

If you’re tired of having to install common gems like Bundler every time you add a new version of Ruby, rbenv-default-gems is for you. It will install gems defined by you as part of doing rbenv install.

Install the plug-in:

git clone ~/.rbenv/plugins/rbenv-default-gems

Define a list of default gems in ~/.rbenv/default-gems like so:

pry --pre
pry-doc '~ 0.5'

Project specific environment variables

If you’d like to use some custom environment variables for a project, rbenv-vars is a nice solution.

Install the plug-in:

git clone ~/.rbenv/plugins/rbenv-vars

Define custom environment variables in a .rbenv-vars:


This example will apply some garbage collection tweaks when Ruby is run from this folder.


Rbenv is a great customizable way of managing multiple ruby installations. In closing, I’d like to thank Sam Stephenson for it and its associated plug-ins.

photo of Jesper Kjeldgaard

Software Engineer
comments powered by Disqus