A Guide to using rbenv (Mac)

Your ruby environment should be a peaceful place to navigate.

Sean Norton
2 min readApr 22, 2019

--

This will cover: how to install, update and keep track of your ruby version with rbenv Most of this information is stripped from the rbenv docs. I wanted to take the more important parts and put them all in one place.

Setting up rbenv

  1. Install rbenv. You’ll need Homebrew installed onto your machine, if you don’t already. Note: that the code below also installs ruby-build, so you'll be ready to install other Ruby versions out of the box.
$ brew install rbenv

2. Initialize rbenv. Run $ rbenv init and follow the instructions to set up rbenv integration with your shell. This is the step that will make running ruby "see" the Ruby version that you choose with rbenv.

3. Close your Terminal window and open a new one so your changes take effect.

Download/Install ruby versions

  1. List all ruby versions available for download
$ rbenv install -l

This should show you a rather long list of different ruby versions available. Like in this image.

2. Select the ruby version you want to install, you’ll replace the end with the version you want to install. I’ve just put 1.8.6-p36 since it is in the example image.

$ rbenv install 1.8.6-p36

Note: This does not set this to the version of ruby your computer is using. this only installs this version onto your machine so you can then later set it.

Actually setting and checking the ruby version

Check all installed ruby versions

This will list the versions ready to be set.

$ rbenv versions

Set rbenv local version

You will use this command to set the local version, replacing the version with the one you want and have already installed.

$ rbenv local 2.5.0-dev

Checking the set local version

$ rbenv local

Removing the set local version

$ rbenv local --unset

Note: the same commands except for --unset work for global, by using $ rbenv global ...

Updating rbenv to have the latest ruby versions

To upgrade to the latest rbenv and update ruby-build with newly released Ruby versions, upgrade the Homebrew packages:

$ brew upgrade rbenv ruby-build

Originally posted April 20th, 2018.

--

--

Sean Norton

Software Developer, focusing on Javascript and other front end technologies.