153

I just updated my Mac to OSX 10.11 El Capitan and some gems didn't remain.

The problem arose when I tried to run installations of different gems... e.g.:

> sudo gem install compass

Once I execute, I get the error:

> ERROR:  While executing gem ... (Errno::EPERM) Operation not permitted

This happens with other gems, as well...

I've run Homebrew and tried to install Ruby again, but nothing is working.

Angelfirenze
  • 99
  • 1
  • 14
Roy Calderon
  • 6,361
  • 3
  • 22
  • 21

2 Answers2

447

I found the answer on SASS issues: https://github.com/sass/sass/issues/1768

Since OSX el Capitan there is a new security function that prevents you from modifying system files called Rootless. So you have 2 options:

  • If you install gems on /usr/local/bin there will be no problem because rootless doesn't affect this path.

  • sudo gem install -n /usr/local/bin GEM_NAME_HERE

Roy Calderon
  • 6,361
  • 3
  • 22
  • 21
  • 2
    To build on what Roy said, [here](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/El_Capitan_and_Homebrew.md#if-usrlocal-does-not-exist) is a link to the homebrew docs on the issue, and [here](https://www.reddit.com/r/ruby/comments/3n26gt/upgrade_to_el_capitan_with_homebrew_ruby/) is a link from Reddit detailing a proper upgrade; perhaps you could see if trying anything there would help. – take Oct 02 '15 at 05:04
  • 1
    "disable rootless function and install gems after the reboot" did not work for me. However, "sudo gem install -n /usr/local/bin GEM_NAME_HERE" solved my problem. Thanks. – Nitesh Borad Jan 01 '16 at 08:04
  • 2
    This solution witch `sudo gem install -n /usr/local/bin GEM_NAME_HERE` **worked perfect** for me (OS X 10.11.1). Install sass and compass again, was easy with this command. Btw it seems to be the most prominent solution for that. e.g. to find here: https://github.com/sass/sass/issues/1768 And in exisiting issue here: http://stackoverflow.com/questions/31972968/cant-install-gems-on-os-x-el-capitan – Herr_Hansen Jan 07 '16 at 17:51
  • I run gem install on MAC OS from VNC. for some reasons, It returns error ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - . Then the command: sudo gem install -n /usr/local/bin GEM_NAME_HERE work well for me. thanks – biolinh Mar 02 '16 at 07:41
  • http://stackoverflow.com/a/33043199/1816277 – Blank Mar 08 '16 at 21:38
  • doesn't work for me. I got this error While executing gem ... (TypeError) no implicit conversion of nil into String – emoleumassi Oct 17 '16 at 12:19
  • you can make it the default by echo "gem: -n/usr/local/bin" >> ~/.gemrc – Abdellah Stands with Palestine Oct 13 '17 at 09:41
  • Without sudo: `gem install --user-install GEM`. No permission required, pod will be installed into `~/.gem/`. – Pavel Shorokhov Oct 29 '20 at 23:06
11

You are experiencing this issue because of a new security feature called System Integrity Protection

You can disable SIP by following the process mentioned below:

  1. Reboot your Mac into Recovery Mode by restarting your computer and holding down Command+R until the Apple logo appears on your screen.
  2. Click Utilities > Terminal.
  3. In the Terminal window, type in csrutil disable and press Enter.
  4. Restart your Mac.
  • 1
    That's right Abid. Thanks However, the other solution its easier IMO – Roy Calderon Oct 03 '15 at 21:16
  • Installing gem at **/usr/local/bin** is a cool solution considering **"Roorless"**, I am not sure though but you may experience issues while executing something from **/usr/lib/...** folder e.g. MySQL can cause issues with libmysqlclient.18.dylib I believe Apple will come up with some guideline or solutionas **"Rootless"** will cause issues with developers – Abid Ur Rehman Oct 04 '15 at 17:00
  • For me, adding "rootless=0" as a boot argument didn't work, however using csrutil did. Thanks! – Endareth Feb 16 '16 at 05:40
  • 16
    Disabling rootless is a bad idea. Don't unless you have a good reason. Needing to install a gem is not a good reason. – tbodt Mar 09 '16 at 21:19
  • yes, it works fine. Thank u brother. – Ios App developer Apr 20 '18 at 09:16