I am Hack Sparrow
Captain of the Internets.

OS X El Capitan screwed up Ruby gems, and how to fix it

After I updated my MacBook Pro's OS to El Capitan, all the command line tools installed via Ruby gems were gone - command not found. Here is what I experienced and how I fixed it.

On trying to reinstall the gems using gem install, I was met with a permission error. Usually this kinda issues are fixed with the use of sudo (even if not recommended), but not this time - even sudo was faced with a permission error.

I got to learn that this was because of Apple's System Integrity Protection (SIP) feature. It protects certain processes and directories even from the root user or users in the sudoers list.

In my case I happened to be using the OS' default Ruby installation (located at /usr/bin/ruby), because of which I was not able to install the gems in the protected gems directory.

So I installed my own copy of Ruby using brew at /usr/local/bin, a directory which SIP makes an exception, IF it already exists. Since I was already using brew, I had this directory on my system.

Before you can install packages using brew in El Capitan, you will need to change the permission of the /usr/local directory as shown below:

$ sudo chown -R $(whoami):admin /usr/local

With that I was able to reinstall all the Ruby gems on the system. The overall commands look like this:

$ sudo chown -R $(whoami):admin /usr/local
$ brew update
$ brew install ruby
$ gem install jekyll

If you don't have the the /usr/local directory, refer this document for details.

6 Responses to “OS X El Capitan screwed up Ruby gems, and how to fix it”

  1. Bruno says:

    Thanks Man!! thanks a lot for submitting this post!!

  2. Matt says:

    Thanks. This helped me out.

  3. GitSyncApp says:

    Dont install Jekyll with Homebrew, Hombrew is bad practice and a security risk:

    Here is how you install it without homeBrew: in el capitan: http://digitalshore.io/how-to-install-jekyll-mac-os-x-el-capitan/

  4. Vin says:

    Thanks a tone… this helped to resolve my issues.

  5. Jim says:

    Many thanks. Big help!

  6. sax says:

    Hello i have probleme with install of : ruby-2.3.0

    MacBook-Pro-de-saxdevweb:bin saxdevweb$ brew update
    Already up-to-date.
    MacBook-Pro-de-saxdevweb:bin saxdevweb$ brew install ruby

    Warning: ruby-2.3.0 already installed, it’s just not linked

    my problem is warning is not linked

Make a Comment