How To Change Ruby Version Mac


Ruby is a popular programming language known for its simplicity and elegance. However, as with any programming language, new versions are released over time, and it’s important to keep up with these updates to ensure compatibility and maintain access to new features. In this blog post, we will walk you through the steps to change your Ruby version on a Mac.

Step 1: Install a Ruby Version Manager

A Ruby version manager is a tool that helps you switch between different Ruby versions with ease. There are several popular version managers available, but we recommend using rbenv or RVM for managing Ruby versions on a Mac. We’ll be using rbenv in this tutorial.

To install rbenv and ruby-build (a plugin that provides an rbenv install command), use the following terminal command:

            brew install rbenv ruby-build

After the installation is complete, add the following line to your .bashrc or .zshrc file to initialize rbenv:

            if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

Restart your terminal or run the following command to apply the changes:

            source ~/.bashrc

Now, you should have rbenv installed and ready to manage your Ruby versions.

Step 2: Install the Desired Ruby Version

With rbenv installed, you can now install the Ruby version you want to switch to. You can find a list of available Ruby versions using the following command:

            rbenv install -l

Once you’ve found the version you want to install, use the following command to install it:

            rbenv install <ruby-version>

Replace with the version number you want to install, for example, 2.7.3.

Step 3: Set the New Ruby Version as the Default

After installing the desired Ruby version, you can set it as your default version using the following command:

            rbenv global <ruby-version>

Replace with the version number you want to set as the default, for example, 2.7.3.

To verify that your Ruby version has been updated, run the following command:

            ruby -v

You should now see the new Ruby version as the output.


In this blog post, we’ve shown you how to change your Ruby version on a Mac using rbenv. With these simple steps, you can easily switch between different Ruby versions to maintain compatibility and access new features. Happy coding!