Update Ruby For Mac



This article explains why you should avoid using the version of Ruby bundled with Mac OS X and should instead install your own version of Ruby with RVM, the Ruby Version Manager.

  1. Latest Mac Os Update Problems
  2. Install Ruby Mac
  3. Update Ruby 2.6 Mac
  4. Update Ruby On Mac

Nov 27, 2017 Questions: I have created a new user account on my mac and I am trying to update to the current version of ruby on it (1.9.2) from the snow leopard default of 1.8.7. Can somebody point me to tutorial or explain the best method to update Ruby on my mac from 1.8 to 1.9.2? RubyGems, the Ruby package manager, should be installed on your machine if you previously have installed Ruby. Verify this by running: which gem Update RubyGems. To update to its latest version with: gem update -system Install gems. To install a gem (Ruby package), run: gem install.

Hands Off the System Ruby

Apple bundles the Ruby programming language with OS X. However, the main caveat for using the bundled version, called the system Ruby, is that Apple bundles Ruby for it’s own use. Therefore, it’s best not to make changes to the system Ruby.

You’ll know when you’re about to change the system Ruby when you need to prefix a gem installation with sudo, for example:

Another reason for not using the system Ruby is that it’s often several versions behind the latest stable version.

The Ruby Version Manager

A better alternative to using the system Ruby is to install Ruby with RVM, the Ruby Version Manager. RVM is a tool for installing different versions of Ruby itself. RVM has the following advantages:

  1. RVM enables you to install multiple versions of Ruby and allows you to change which version you want to use.
  2. RVM installs each version of Ruby in a hidden folder in your home folder so each version of Ruby you install doesn’t affect the system Ruby.
  3. Gems installed by RVM-managed versions of Ruby are installed within the hidden folder in your home folder containing that version of Ruby.
  4. You won’t need use sudo to install gems.

To check that you’re currently using the system Ruby, open Terminal and type the following:

If you’re using the system Ruby, OS X will respond with:

You can check which version of Ruby OS X is using with:

Installing RVM and Ruby

Latest Mac Os Update Problems

Ruby for mac os x

The RVM install page has comprehensive instructions for installing RVM that work on Mac OS X. I’ll provide the steps I used here.

Install Ruby Mac

The first step is to install the mpapis public key. However, as the install page notes, you might need gpg. Mac OS X doesn’t ship with gpg so before installing the public key, you’ll need to install gpg. I installed gpg with Homebrew:

After you’ve installed gpg, you can install the mpapis public key:

I've listed the mapis public key install command here for illustration. You should use the version on the RVM install page.

I chose to install RVM with the latest stable version of Ruby, which at the time was 2.2.0:

After the installation completes, close the Terminal window and open a new one to make sure that Terminal picks up any environment changes.

Update Ruby 2.6 Mac

Update Ruby For Mac

Using RVM

You can list the versions of Ruby available to RVM with rvm list:

Update Ruby On Mac

The rvm use command selects a version of Ruby:

You can check that you’re using an RVM-managed version of Ruby with:

OS X now responds with:

which tells us we’re using version 2.2.0 and that version 2.2.0 has been installed in my home folder away from the system Ruby. You can confirm this by asking Ruby itself with:

The RVM-managed version of Ruby responds with:

Update ruby for mac os

As I mentioned earlier, gems installed with RVM-managed versions of Ruby are located with the Ruby. You can check where gems will be installed with:

The following lines of output shows that gems will be installed in the folder XXX.

To find out where a particular gem is installed, use the gem which command. For example, gem which jekyll locates the Jekyll gem:

Are you not sure which Ruby version you are using right now? Wondering how to check it? Say no more. Here are two simple ways to check for it.

In irb

Run irb and type:

From command line

Just type ruby -v

In RVM

Are you using RVM?

Ruby

Run rvm current and get the answer

In rbenv

Are you using rbenv? Just run rbenv version

Using which

Do you want to know where your ruby binary is installed? It can also sometimes reveal the version you are using as it is usually part of directory structure. Just run which ruby.

Using gem env

If you want to know even more about your current ruby setup, there is a command for that as well!