4

Does anybody know why after updating to Mac OS El Capitan gem has started giving errors for install or update commands?

Example:


$ sudo gem update
Password:
Updating installed gems
Updating bundler
ERROR:  While executing gem ... (Errno::EPERM)
  Operation not permitted - /usr/bin/bundle

For some reason the path has to be set explicitly. Example:


$ sudo gem install -n /usr/local/bin sass
Password:
Fetching: sass-3.4.19.gem (100%)
Successfully installed sass-3.4.19
Parsing documentation for sass-3.4.19
Installing ri documentation for sass-3.4.19
Done installing documentation for sass after 6 seconds
1 gem installed

This is pretty annoying! Is there a way to make /usr/local/bin default?

Kim Hogeling
  • 641
  • 6
  • 14
  • 1
    Recommended reading for those finding this question https://stackoverflow.com/questions/32891965/error-while-executing-gem-errnoeperm-operation-not-permitted?rq=1 – JGallardo Nov 08 '15 at 07:45

3 Answers3

4

This is not directly answering your question, but since your accepted answer is a little dangerous, I would like to share how I solved the actual issue of not being able to install a gem.

In my case I was having a problem with compass and had the same error, which is what I entered in my search and Google brought me here. I ran

sudo gem install -n /usr/local/bin compass

But if you are doing a fresh install on a new computer. Make sure that you have bash installed. Here is a brief transcript of what I did.

enter image description here

JGallardo
  • 11,074
  • 10
  • 82
  • 96
2

Having the same problems, found this:

  • Boot into the Recovery HD by restarting whilst holding ⌘R.
  • Open Terminal (from the Utilities menu).
  • Run the following command in Terminal: csrutil disable
  • Restart

source: https://georgegarside.com/blog/osx/package-incompatible-installer/

skeltont
  • 86
  • 8
  • I did not know anything about OS X El Capitan Rootless. Thank you for the explanation and steps for disabling. I did not like to disable it, but it worked like a charm! – Kim Hogeling Oct 19 '15 at 21:30
  • 5
    This is extremely dangerous, and should be accompanied with warnings that this operation disables an important OS X security feature. – eyelidlessness Oct 19 '15 at 23:10
  • 2
    Yeah, @eyelidlessness here's an article recommending keeping it on. I should have provided more background info. http://www.howtogeek.com/230424/how-to-disable-system-integrity-protection-on-a-mac-and-why-you-shouldnt/ – skeltont Oct 20 '15 at 17:28
  • There are 4 options when i rebooted. Where was this Utilities menu? – JGallardo Nov 08 '15 at 07:44
2

If you use homebrew, there is another solution you can try in the below commands. This does involve installing the homebrew version of Ruby. This fixed the problem for me, although I'm middling in my knowledge of Unix. So I can't speak to how wise or unwise it is to give yourself ownership of /usr/local. Maybe a Unix expert can chime in here.

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

Source: http://www.hacksparrow.com/os-x-el-capitan-screwed-up-ruby-gems-and-how-to-fix-it.html

Dave Munger
  • 479
  • 3
  • 11