A place setting at a dining table, with many similar-looking utensils.
Start at the outside and work your way in. Photo attribution here.

A little while ago, I wrote a thing called "The Impostor's Guide To The Shell", where I describe how I taught myself the basics of shell scripting by reading the codebase of a program called RBENV.

RBENV is a version manager for the Ruby programming language. It's a popular choice for managing Ruby versions, but it's not the only choice. Others include rvm, chruby, asdf, or other programs.

Most people just use the same version manager that their team does. But if your team is new and deciding which version manager to use (or if you're a solo engineer and don't have a team), it can be difficult to differentiate between these different options.

In addition, you may have heard of other "managers", such as Bundler. It's easy to get confused about the difference between version managers and other types of package managers. Let's learn about the difference between all these different tools in our toolbelt.

RBENV vs. other version managers

In my blog post "What Is A Shim?", I describe how RBENV uses the concept of a "shim" to intercept your call to (for example) the ruby command in your terminal. Once it has done this, it can select the correct version of Ruby to use based on your project's settings, and then pass your call to ruby on to that correct version.

Not all version managers work this way. RVM, for example, works by overriding your terminal's cd command. In fact it was this design choice (and the corresponding trouble it caused for certain users) which led to the development of RBENV in the first place.

The core RBENV team actually maintains a comparison of popular Ruby version managers here.

RBENV vs. Bundler

According to its homepage, Bundler provides "a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed."

This... sounds a lot like what I just said RBENV does. So what's the difference between RBENV and Bundler? Why do I need both?

Bundler is a dependency management tool. It helps you manage the versions of the Ruby libraries in a specific project folder (also known as "gems"). These gems are the libraries that the project in this folder depends on (a.k.a. "dependencies").

RBENV, on the other hand, manages the versions of Ruby itself, across all the Ruby projects on your machine. RBENV ensures that your machine is using the version of Ruby that your project depends on, and Bundler ensures that your machine is using the right versions of the libraries that your project depends on.

While Ruby is technically a "dependency" too, it's really more than that. You can't run a Ruby project without an installed Ruby version, whereas you could still run a Ruby project without a given library (by simply removing the feature or features which depend on that library).

More info on how these tools all work together can be found here, in this excellent summary from Honeybadger.io.

Photo Attribution

Title of Photo: 13 course place setting

Description: 13 course table setting French style overhead view

Author: Hopefulromntic21

Source: Wikimedia Commons

License: CC BY-SA 4.0 DEED Attribution-ShareAlike 4.0 International