If you’re starting out with Ruby or Ruby on Rails development, you’ll want to know:
- How to properly install Ruby on Mac.
- How to setup a local development environment that doesn’t conflict with
brewor an existing install of Ruby 2.7 Mac
In this tutorial, you’ll learn how to do both! If you have the new macOS M1 laptops, don’t worry, this tutorial also works for installing Ruby on Mac M1.
Never run brew install ruby
Some guides and blog articles will instruct you to install Ruby by running brew install ruby or updating your existing Ruby versions on a macOS by running the update ruby mac command. I highly recommend you avoid that completely.
That said, Reddit user postmodern shared on a Ruby thread that you could probably instruct the brew installation to be explicitly installed onto a different directory. Brew by default installs to /usr/local and according to postmodern, this doesn’t interfere with the Apple system Ruby scripts because their interpreter location is hardcoded to /usr/bin/ruby.