You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user)

You are correct that macOS won't let you change anything with the Ruby version that comes installed with your Mac. However, it's possible to install gems like bundler using a separate version of Ruby that doesn't interfere with the one provided by Apple.

Using sudo to install gems, or changing permissions of system files and directories is strongly discouraged, even if you know what you are doing. Can we please stop providing this bad advice?

The solution involves two main steps:

  1. Install a separate version of Ruby that does not interfere with the one that came with your Mac.
  2. Update your PATH such that the location of the new Ruby version is first in the PATH. The list of directories, and the order in which the computer looks them up to find executable programs is called the PATH. If you type echo $PATH in Terminal, you will see the list of directories, separated by a colon.

There are several ways to install Ruby on a Mac. The best way that I recommend, and that I wish was more prevalent in the various installation instructions out there, is to use an automated script that will set up a proper Ruby environment for you. This drastically reduces the chances of running into an error due to inadequate instructions that make the user do a bunch of stuff manually and leaving it up to them to figure out all the necessary steps.

The other route you can take is to spend extra time doing everything manually and hoping for the best. First, you will want to install Homebrew, which makes it easy to install other tools and macOS apps.

Then, the 4 most popular ways to install a separate version of Ruby are:

If you don't need more than one version of Ruby at the same time (besides the one that came with macOS)

  • Homebrew - once it's installed, install ruby with brew install ruby, then update your PATH by running echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile, followed by source ~/.bash_profile

If you would like the flexibility of easily switching between many Ruby versions

  • chruby and ruby-install - my personal recommendations and the ones that are automatically installed by the aforementioned script. These can be installed with Homebrew.

  • rbenv - can be installed with Homebrew

  • RVM

To check that you're now using the non-system version of Ruby, you can run the following commands:

which ruby

It should be something other than /usr/bin/ruby

ruby -v

It should be something other than 2.3.7. As of today, 2.6.1 is the latest Ruby version.

Once you have this new version of Ruby installed, you can now install bundler:

gem install bundler

It's generally recommended to use a version manager like rbenv or rvm. Otherwise, installed Gems will be available as root for other users.

If you know what you're doing, you can use sudo gem install.

If you don't want to run sudo then install ruby using homebrew

brew install ruby
export GEM_HOME="$HOME/.gem"
gem install rails

You may want to add export GEM_HOME="$HOME/.gem" to your ~/.bash_profile or .zshrc if you're using zsh

I have faced same issue after install macOS Catalina. I had try below command and its working.

sudo gem update

Solution for Mac

  1. Install/update RVM with last ruby version

    \curl -sSL https://get.rvm.io | bash -s stable --rails

  2. Install bundler

    gem install bundler


after this two commands (sudo) gem install .... started to work

Run this

$ rbenv init
# Load rbenv automatically by appending
# the following to ~/.zshrc:

eval "$(rbenv init -)"

Follow instructions, (in my case add to ~/.zshrc) ;)


Also important: Changes only take effect if you reboot your console. Two options

  • Enter source <modified file>
  • close and open again