How to Update Ruby Version in macOS
- Update Ruby Version in macOS Using Homebrew
-
Update Ruby Version in macOS Using
rvm
-
Update Ruby Version in macOS Using
rbenv
Although macOS comes pre-installed with Ruby, the pre-installed version is usually behind, and there’s usually a need to have a more recent version. This tutorial will look at different ways of installing Ruby on Mac.
Update Ruby Version in macOS Using Homebrew
brew install ruby
Running the above command in a terminal installs the latest version of Ruby.
Suppose you will be working on different projects that require different Ruby versions. In that case, a version manager is needed. rbenv
and rvm
are the two most popular Ruby version managers, and below are the steps to follow to install Ruby via any of these two methods.
Update Ruby Version in macOS Using rvm
-
Install
rvm
curl -sSL https://get.rvm.io | bash -s stable --ruby
-
Close and re-open your terminal. Then, Install the latest version of Ruby
rvm install ruby(--latest)
You can also install a specific version with rvm install 2.7.0
. Then, Get a list of all versions you’ve installed.
rvm list
The above command lists all installed versions, and the active(current) version is indicated.
To switch between versions, say we want to switch to version 2.7.0, run rvm use 2.7.0
.
To read more about rvm
, you can check the official documentation.
Update Ruby Version in macOS Using rbenv
-
Install
rbenv
brew install rbenv
-
Set up
rbenv
in your shellrbenv init
-
Close and re-open your terminal so your changes can take effect
-
Install a Ruby version
rbenv install 2.7.0
Get a list of all versions you’ve installed
rbenv versions
To switch to a specific version, run rbenv global 2.7.0
To check the active(current) version, run rbenv version
.
To read more about rbenv
, here’s the official documentation.