How to install the latest ruby version on M1/M1 Pro/M1 Max Macs?

December 08, 20212 min read#iOS, #Swift, #MacBook, #M1, #tool, #ruby

Ruby, for some reasons, has become an essential part of iOS Development tool belt. With popular tools written in Ruby such as cocoapods or fastlane, installing Ruby is one of the first task most iOS developers do when setting up a new development environment.

Unfortunately, the preinstalled version of Ruby on Macs is outdated. For my new Macbook Pro 14 Inch (Dec 2021), the preinstalled Ruby is at version 2.6.8p205 . And the latest stable version of Ruby is 3.0.3

In this article, I’ll show you some easy steps to install the latest Ruby version on your new MacBooks.

We are going to use rbenv to seamleassly manange the Ruby environment.

Install rbenv

# Install rbenv
brew install rbenv

# Initialise rbenv
rbenv init

Verify rbenv

➜  ~ curl -fsSL | bash

Checking for `rbenv' in PATH: /opt/homebrew/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /opt/homebrew/bin/rbenv-install (ruby-build 20211203)
Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `/Users/antran/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 3.0.3
Checking RubyGems settings: OK
Auditing installed plugins: OK

Install ruby

List latest stable versions:

➜  ~ rbenv install -l

Install Ruby 3.0.3

➜  ~ rbenv install 3.0.3
Downloading openssl-1.1.1l.tar.gz...
Installing openssl-1.1.1l...
Installed openssl-1.1.1l to /Users/antran/.rbenv/versions/3.0.3

Downloading ruby-3.0.3.tar.gz...
Installing ruby-3.0.3...
ruby-build: using readline from homebrew
Installed ruby-3.0.3 to /Users/antran/.rbenv/versions/3.0.3

Set global version

 rbenv global 3.0.3


➜  ~ ruby -v
ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [arm64-darwin21]

Profile picture

Personal blog by An Tran. I'm focusing on creating useful apps.
#Swift #Kotlin #Mobile #MachineLearning #Minimalist

© An Tran - 2024