ruby 错误:执行 gem 时 ... (Errno::EPERM) 不允许操作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32891965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 06:46:45  来源:igfitidea点击:

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

rubymacosrubygemsosx-elcapitancompass

提问by Roy Calderon

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

我刚刚将我的 Mac 更新到 OSX 10.11 El Capitan 并且一些宝石没有留下。

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

当我尝试运行不同 gem 的安装时出现了问题......例如:

> 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.

我已经运行 Homebrew 并尝试再次安装 Ruby,但没有任何效果。

回答by Roy Calderon

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

我找到了关于 SASS 问题的答案:https: //github.com/sass/sass/issues/1768

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

由于OSX el Capitan有一个新的安全功能可以防止您修改名为 Rootless 的系统文件。所以你有两个选择:

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

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

  • 如果你安装 gems 就/usr/local/bin没有问题,因为 rootless 不会影响这个路径。

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

回答by Abid Ur Rehman

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:

您可以按照下面提到的过程禁用 SIP:

  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. 通过重新启动计算机并按住 Command+R 直到 Apple 标志出现在屏幕上,将 Mac 重新启动到恢复模式。
  2. 单击实用程序 > 终端。
  3. 在终端窗口中,输入 csrutil disable 并按 Enter。
  4. 重新启动您的 Mac。