In this quick guide I'll show you the direct steps to install ruby on M1.
If you need to run at any point an app that does not support M1, right click that app and on info, you can toggle the option "Rosetta".
The installation will be composed of multiple software:
- Homebrew - Will be used as main source for getting/upgrading our software.
- rbenv - To be able to upgrade/downgrade & even install multiple Ruby versions. Very convenient.
Install rbenv
Use rbenv to pick a Ruby version for your application and guarantee that your development environment matches production. Put rbenv to work with Bundler for painless Ruby upgrades and bulletproof deployments.
Powerful in development. Specify your app's Ruby version once, in a single file. Keep all your teammates on the same page. No headaches running apps on different versions of Ruby.
How It Works
At a high level, rbenv intercepts Ruby commands using shim executables injected into your PATH
, determines which Ruby version has been specified by your application, and passes your commands along to the correct Ruby installation.
For mroe info, check how PATH & Shims works.
To install rbenv with Homebrew type:
brew install rbenv ruby-build
Next, run rbenv init
and follow the instructions.
Now call the doctor 😆 to check that everything is ok:
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
You should be seeing this:
Install Ruby
You can install Ruby by providing the latest suggested version shown on the step above, in my case it would be:
rbenv install 3.1.2
You can call the doctor 🩺 above again to check that it went well.
Check the location where gems are being installed with gem env
:
gem env home
To check the full installation of Ruby and its directory run:
gem environment
Pods
You can install cocoapods with:
gem install cocoapods
Optional - Install Bundler
gem install bundler
Switch Ruby versions
Install a new version using rbenv install 3.1.2
, next set it as global: rbenv global 3.1.2
See versions installed
rbenv versions