这个简单的错误令我难过:
(0)root@vpn-client-228# mkdir ruby-2.0.0-p645
mkdir: ruby-2.0.0-p645: Operation not permitted
(1)root@vpn-client-228# pwd
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0
(0)root@vpn-client-228#
以下是我能想到的所有调试信息:
(0)root@vpn-client-228# dd='/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby-2.0.0-p645'
(0)root@vpn-client-228# while [ "`dirname $dd`" != "/" ]; do dd=`dirname $dd`; ls -ld $dd; done
drwxr-xr-x 5 root wheel 170 Dec 9 10:55 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0
drwxr-xr-x 3 root wheel 102 Aug 22 19:06 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include
drwxr-xr-x 6 root wheel 204 Nov 24 11:19 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr
drwxr-xr-x 7 root wheel 238 Dec 14 09:52 /System/Library/Frameworks/Ruby.framework/Versions/2.0
drwxr-xr-x 4 root wheel 136 Sep 17 07:27 /System/Library/Frameworks/Ruby.framework/Versions
drwxr-xr-x 6 root wheel 204 Dec 9 10:55 /System/Library/Frameworks/Ruby.framework
drwxr-xr-x 135 root wheel 4590 Dec 9 10:55 /System/Library/Frameworks
drwxr-xr-x 79 root wheel 2686 Nov 24 15:40 /System/Library
drwxr-xr-x@ 4 root wheel 136 Dec 14 09:53 /System
(0)root@vpn-client-228#
(0)root@vpn-client-228#
(0)root@vpn-client-228# uname -a
Darwin vpn-client-228.sv2 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
(0)root@vpn-client-228#
(0)root@vpn-client-228#
(0)root@vpn-client-228# id
uid=0(root) gid=0(wheel) groups=0(wheel),1(daemon),2(kmem),3(sys),4(tty),5(operator),8(procview),9(procmod),12(everyone),20(staff),29(certusers),61(localaccounts),80(admin),701(com.apple.sharepoint.group.1),702(com.apple.sharepoint.group.2),33(_appstore),98(_lpadmin),100(_lpoperator),204(_developer),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh)
(0)root@vpn-client-228#
上下文是我试图安装perftools(sudo gem install perftools.rb -v '2.0.0'
)失败,错误/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:in 'mkdir': Operation not permitted - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby-2.0.0-p645 (Errno::EPERM)'
并且我试图调试它。
答案 0 :(得分:4)
没有。就是不行。”不要永远以root身份安装gems。除非你必须,真的知道你在做什么,并且愿意在你搞砸的时候重新安装操作系统。所以只是不要。
始终使用像rvm,rbenv或chruby这样的Ruby版本管理器。即使在生产机器上,这也会为您带来很多悲伤。
特别是,El Capitan有一个新的System Integrity Protection (SIP)系统,它依赖于应用于重要路径和应用程序的特殊标志。 Ruby是其中一个二进制文件:
$ ls -lO /usr/bin/ruby
-r-xr-xr-x 1 root wheel restricted,compressed 42928 Oct 17 19:47 /usr/bin/ruby
虽然我不会发誓,但RubyGems试图修改的文件或目录也可能受到保护。当你可以绕过SIP时,这样做是一个真正糟糕的想法™。相反,您应该使用其中一个版本管理器(Homebrew中包含rbenv和chruby)来安装非系统红宝石并管理宝石。