Skip to main content

14 Ruby Version Managers

Episode 2 · July 2, 2014

Techniques for installing Ruby and managing different versions between applications



There are a bunch of different ways that we can install ruby and I want to talk about ruby version managers today.

The first, default, easiest way to set up ruby is to just download ruby; compile it, and run it. It probably comes with your mac and you can easily install it with Ubuntu's package manager or any other linux distro that you're doing.

However, there are these tools called “ruby version managers”, and RVM is named exactly that. RBENV is another one. These tools allow you to run multiple versions of ruby and keep gems separated out in your different applications.

Why would we want to do this?

Well, you might have an application that’s older; and you need to still work on it occasionally, that only works in ruby 1.8.7. Well, the latest version of ruby at this time is ruby 2.1.2. So in your other projects you’re probably working with 2.1; and you need to be able to switch between these.

RVM, and RBENV, and these other tools allow you to switch between those ruby versions and automatically detect that per application. So your applications can define which version of ruby they use and thats it; you don't need to do anything more.

So whats the difference?

Well RVM is a very full featured version manager; so if you've never done anything with ruby before it might be good to use RVM because there’s so many things that it helps you with.

RBENV however is designed for people that are a little but more familiar with it and want a lightweight version manager. RBENV will set itself up very lightweight. It will add itself to your environment variable called $PATH. Then when you type ruby it will look to your path, find the ruby executable, and then go from there.

RVM will actually take and override some of your environment stuff as well; and go a little bit deeper. It will upgrade the cd command; and several other commands. It also provides these older things called gem sets that allow you to say, “we can name these sets of gems for each application.”

Gem sets are not really useful anymore because we have a tool called BUNDLER. And BUNDLER; as you'll see, has been added in more recent versions of rails as the default. Your gem file is the one that BUNDLER handles, and it keeps all of your gems separated and up to date. You don't have to worry about using gem sets and theres fewer reasons to use RVM anymore unless you’re brand new.

But if you're up to the task...

I recommend using RBENV because its lightweight so you can spend your time learning how it works because its very simple to use.

So if you're brand new you may check out RVM. However, I recommend RBENV for everyone if you're up to the task of learning it.

Its very rare that you'll actually go to download ruby and compile it from source; because you're only allowed one version of ruby, and generally developers tend to work on a bunch of different projects and want to install the latest version of ruby. These tools allow you to do that; but if you do it yourself then you'll have to constantly be messing with things; and thats not super fun.

Thats a really quick rundown of version managers and how they differ from each other. If you're interested check out RBENV and enjoy.

Transcript written by Timothy Ashby


Tom de Bruijn on

Missing chruby in this list,

A really small ruby version manager which does nothing more than manage your ruby versions. Unlike rvm and rbenv it does not come with a ruby installer (rbenv uses ruby-build). You can use ruby-install by the same author for that. Together they make a really lightweight setup for your ruby version management.

Chris Oliver (167,500 XP) on

Yes! I haven't chruby, but hear it's great. Thanks for including the link to that. I'm going to give it a shot soon on a setup and see how it goes.

Bijan Boustani (30 XP) on

What are some caveats in terms of when to install things with sudo and when not to? I use rbenv and occasionally seem to run into issues where I end up accidentally wrecking some of my ruby version installations because I use sudo while installing a gem here or there. Then when I go to bundle a new project it'll prompt me that I don't have access, but I know I also shouldn't bundle with the sudo command. Thanks for the great screencast!

Chris Oliver (167,500 XP) on

With these version managers, you should never need to use sudo. The reason for this is that they install Ruby in your home directory so you own it. That means that installing gems, running bundler, and anything else all happens in your home directory as well. Since you own that folder, you won't be installing somewhere in the system and means that using sudo then would change the ownership to root and cause problems.

Bijan Boustani (30 XP) on

I see. Thanks for the clarification.

Michael Hwan (10 XP) on

If I have rvm and rbenv installed will it cause errors when I work on my Rails application?

I've been getting a lot of errors recently because I have both installed...

Chris Oliver (167,500 XP) on

I'd definitely just stick with one.

Jeff Dembinski (30 XP) on

How do you uninstall one?

Login or create an account to join the conversation.