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
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 brew install rbenv # Initialise rbenv rbenv init
➜ ~ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | 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
List latest stable versions:
➜ ~ rbenv install -l 2.6.9 2.7.5 3.0.3 jruby-188.8.131.52 mruby-3.0.0 rbx-5.0 truffleruby-21.3.0 truffleruby+graalvm-21.3.0
Install Ruby 3.0.3
➜ ~ rbenv install 3.0.3 Downloading openssl-1.1.1l.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1 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... -> https://cache.ruby-lang.org/pub/ruby/3.0/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]