Install Ruby with rbenv on macOS

This post is about rbenv, a development environment managing tool for Ruby. This tool is handy if you need specific Ruby and Ruby gems versions for specific projects. By doing this, you keep your project’s requirements in check.

Installing rbenv with Homebrew:

  1. brew install rbenv
  2. brew install ruby-build
  3. echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
  4. source ~/.bash_profile

Installing Ruby in e.g. version 2.2.3 and defining it default system-wide version:

  1. rbenv install 2.2.3
  2. rbenv global 2.2.3
  3. rbenv rehash
  4. ruby -v