Ruby 2D on macOS

Learn how to set up your Ruby environment on the Mac

macOS comes with a system Ruby, but it doesn’t have the development libraries needed to build native extensions. No problem though, we can use Homebrew to get a proper Ruby environment set up in no time.

Install rbenv with Homebrew

If you don’t already have Homebrew, head over to brew.sh and follow the install instructions. Once that’s ready, install rbenv (a lightweight Ruby version manager) using:

brew install rbenv

Next, run the init command to set up rbenv in your shell:

rbenv init

This will print instructions for adding rbenv to your shell profile. Follow those steps, then restart your terminal (or open a new tab) so the changes take effect.

Install Ruby

Now you can install Ruby and set it as your default. Version 4.0.6 is the latest as we write this, and rbenv install -l will show you the newest available:

rbenv install 4.0.6
rbenv global 4.0.6

Check to make sure everything works (the $ symbol represents the prompt):

$ ruby -e "puts 'Hello Ruby'"
Hello Ruby

That’s it! Head back to the “get started” guide and write your first 2D app »


Suggest an edit to this page