OS X El Capitan - 无法使用gem安装bundler

时间:2015-10-28 03:15:16

标签: ruby-on-rails ruby bundler osx-elcapitan

我刚刚安装了El Capitan,不得不安装导轨。我正在尝试安装bundler但是收到以下错误。我在stackexchange上找到了这个答案,但好像我会搞一个安全问题https://apple.stackexchange.com/questions/204312/cant-install-bundler-using-gem

sudo gem install bundler --no-ri --no-rdoc
Password:
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/bundle

更新

$ rvm gem install bundler --no-ri --no-rdoc
Please note that `rvm gem ...` was removed, try `gem install bundler --no-ri --no-rdoc` or `rvm all do gem install bundler --no-ri --no-rdoc` instead. ( see: 'rvm usage' )
$ gem install bundler --no-ri --no-rdoc
Fetching: bundler-1.10.6.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
$ sudo gem install bundler --no-ri --no-rdoc
Password:
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/bundle
$ rvm all do gem install bundler --no-ri --no-rdoc
$ bundle
zsh: command not found: bundle
$ sudo gem install bundler --no-ri --no-rdoc
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/bundle
$ rvm gem install bundler --no-ri --no-rdoc
Please note that `rvm gem ...` was removed, try `gem install bundler --no-ri --no-rdoc` or `rvm all do gem install bundler --no-ri --no-rdoc` instead. ( see: 'rvm usage' )
$ rvm gem install bundle --no-ri --no-rdoc
Please note that `rvm gem ...` was removed, try `gem install bundle --no-ri --no-rdoc` or `rvm all do gem install bundle --no-ri --no-rdoc` instead. ( see: 'rvm usage' )

3 个答案:

答案 0 :(得分:2)

您可能正在使用El Capitan的新功能System Integrity Protection

但是,您真的不想在系统ruby中安装宝石和东西进行开发。我这样做了很多年,但实际上,除了头痛并使用RVMrbenv之外。

答案 1 :(得分:1)

来自https://github.com/bundler/bundler/issues/4065

您需要更改GEM_HOME或执行

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

因为El Cap引入了SIP(系统完整性保护)。

答案 2 :(得分:0)

OS X 10.11有一个所谓的"无根"功能,禁止用户修改/usr目录。唯一的例外是/usr/local。所以sudo在这里毫无用处。我建议使用rbenv在其他地方安装新的ruby安装。