. Advertisement .
..3..
. Advertisement .
..4..
Ruby is an open-source programming language that offers a strong developer focus. Its main purpose is web development, while Ruby is also used as a scripting language.
How to update the Ruby version on Mac? This article will show you the best updating methods for this easy-to-learn and fun-to-use program.
How To Install Ruby On Mac
Prepare a proper internet connection and administrator privileges before installing Ruby. Then, run the following command to activate the terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install ruby
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
You can install the updated versions by a package manager. Following the above code, now you should use the below input to run the package manager:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
How To Upgrade The Ruby Version On Mac
There are three methods to update your Ruby versions:
Method 1: Use Homebrew
Running a simple command in Homebrew is one of the most straightforward to check and upgrade your Ruby version. Type the following code in a terminal:
brew install ruby
Method 2: Use rvm
Different projects will require their specific Ruby versions. That’s why you need to have a version manager. rvm is one of the two most popular version managers of Ruby. Here are detailed steps to update Ruby using rvm:
- Step 1: Install
curl -SSL https://get.rvm.io | bash -s stable --ruby
- Step 2: Open a terminal and install the latest Ruby version.
rvm install ruby --latest
This step will take a while to finish due to various dependencies. It will also ask for your permission a couple of times during this time. Make sure to pay attention to it.
Besides upgrading, you can also access a list of all Ruby versions with rvm install 2.7.0.
Type rvm list, see which version is active, and switch to your desired one. If you want to use version 2.7.0, run the command rvm and use 2.7.0.
Method 3: Use rbenv
- Step 1: Install by typing the code
brew install rbenv
- Step 2: Set up your shell
rbenv init
- Step 3: Activate by closing and reopening your terminal
- Step 4: Install a new Ruby version
rbenv install 2.7.0
To get a list of all installed versions, run the command rbenv versions.
Now you can go to your project’s directory, run the bundle, and have your work done:
cd work/luther.io
bundle install
bundle exec Jekyll s --config _config.yml,_config_dev.yml
Conclusion
macOS is often pre-installed with Ruby. Yet, this version is often behind the date and needs to be upgraded. This tutorial has shown you how to update the Ruby version on Mac. All the methods come with in-depth instructions with an extra-credit section.
Leave a comment