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: