Manage Ruby on macOS using rbenv

Use a combination of Homebrew and rbenv to manage Ruby on macOS.

First, ensure Homebrew Ruby and rbenv are installed. Now we’re ready to manage our local Ruby installation via rbenv.

List all available Ruby versions that can be installed.

rbenv install -l
[...]
  2.6.0
  2.6.1
  2.6.2
[...]

Install a Ruby version.

rbenv install 2.6.2

Activate this newly installed version as the default (global).

rbenv global 2.6.2

Get the list of locally installed Ruby versions.

rbenv versions
  system
  2.3.1
  2.6.0
* 2.6.2 (set by /Users/mike/.rbenv/version)

You can delete outdated versions manually inside ~/.rbenv/versions or use the uninstaller:

rbenv uninstall 2.3.1

Before installing gems, check the default gem installation path.

gem env home
/Users/mike/.gem

Now we’re ready to install gems, such as bundler.

gem install bundler

Fianlly, ensure all installed gems are up to date.

gem update