无法在 OS X“El Capitan"上安装 gems [英] Can't install gems on OS X "El Capitan"
问题描述
我无法在 El Capitan Beta 5 上安装和运行 fakes3
gem.
I am not able to install and run fakes3
gem on El Capitan Beta 5.
我试过了:
sudo gem install fakes3
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/fakes3
然后我尝试用 cocoapods 的方式来做.它适用于 cocoapods,但不适用于 fakes3.
Then I tried doing it the cocoapods way. It worked for cocoapods but not for fakes3.
mkdir -p $HOME/Software/ruby
export GEM_HOME=$HOME/Software/ruby
gem install cocoapods
[...]
1 gem installed
gem install fakes3
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
推荐答案
免责声明: @theTinMan 和其他 Ruby 开发人员经常指出在安装 gems 和指向诸如 RVM 之类的内容.在进行 Ruby 开发时,这是绝对正确的.继续使用它.
Disclaimer: @theTinMan and other Ruby developers often point out not to use sudo
when installing gems and point to things like RVM. That's absolutely true when doing Ruby development. Go ahead and use that.
然而,我们中的许多人只想要一些恰好作为 gem 分发的二进制文件(例如 fakes3
、cocoapods
、xcpretty
...).我绝对不想费心管理一个单独的 ruby.以下是您更快的选择:
However, many of us just want some binary that happens to be distributed as a gem (e.g. fakes3
, cocoapods
, xcpretty
…). I definitely don't want to bother with managing a separate ruby. Here are your quicker options:
如果您希望全局安装这些工具,则使用 sudo
可能没问题.
Using sudo
is probably fine if you want these tools to be installed globally.
问题是这些二进制文件安装在 /usr/bin
中,也就是 禁区 自 El Capitan 起.但是,您可以将它们安装到 /usr/local/bin
中.那就是 Homebrew 安装它的东西的地方,所以它 可能已经存在.
The problem is that these binaries are installed into /usr/bin
, which is off-limits since El Capitan. However, you can install them into /usr/local/bin
instead. That's where Homebrew install its stuff, so it probably exists already.
sudo gem install fakes3 -n/usr/local/bin
Gems 将安装到 /usr/local/bin
并且您系统上的每个用户都可以使用它们,如果它在他们的 路径.
Gems will be installed into /usr/local/bin
and every user on your system can use them if it's in their PATH.
以下将在 ~/.gem
中安装 gems 并将二进制文件放入 ~/bin
(然后你应该将其添加到你的 PATH
).
The following will install gems in ~/.gem
and put binaries in ~/bin
(which you should then add to your PATH
).
gem install fakes3 --user-install -n~/bin
将其设为默认值
无论哪种方式,您都可以将这些参数添加到您的 ~/.gemrc
中,这样您就不必记住它们:
Make it the default
Either way, you can add these parameters to your ~/.gemrc
so you don't have to remember them:
gem: -n/usr/local/bin
即echo "gem: -n/usr/local/bin" >>~/.gemrc
或
gem: --user-install -n~/bin
即echo "gem: --user-install -n~/bin" >>~/.gemrc
(提示:你也可以加入 --no-document
跳过生成 Ruby 开发者文档.)
(Tip: You can also throw in --no-document
to skip generating Ruby developer documentation.)
这篇关于无法在 OS X“El Capitan"上安装 gems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!