##Switching to Rbenv


I’ve noticed that I have way to many versions for ruby on my machine and it’s time to clean them up. For the last few years I’ve been using RVM to manage my ruby versions. It’s been extremely helpful but it’s become a little bit to heavy.

  1. RVM overrides cd. Dangerous!

If you have two projects with different ruby versions, when you switch project directories RVM knows which ruby should be used. How does it know this? It overrides the cd function. When installing RVM you have to add the following to you bash file:

[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm

That line adds a variety of scripts. You can check out what RVM is doing on the github page.

  1. Gemsets

With bundler Gemsets is unnecessary. We have bundler and there is no reason to use something else to manage gems and dependencies. There are a few other good reasons over on the rbenv github page

So how do I get rid of RVM? Simple!

$ rvm implode

You’ll also want to remove the entries from your bash file. Now we can install rbenv. I’m using a Mac so homebrew is the way to go.

$ brew update
$ brew install rbenv ruby-build

Now we just need to add the following to our shell:

  export PATH="$HOME/.rbenv/shims:$PATH"
  if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

We can easily install ruby versions:

  $ rbenv install 2.2.2
  $ rbenv local 2.2.2
  $ rbenv rehash

rbenv allows you to set a global version through rbenv global version or a local directory version with local. rehash manually rebuilds the shims so everything is update and working correctly. These are just the basics and you can check out some other details on the github project.

Comments