无法在OS X上安装宝石“El Capitan” [英] Can't install gems on OS X "El Capitan"

查看:147
本文介绍了无法在OS X上安装宝石“El Capitan”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在El Capitan Beta 5上安装并运行 fakes3 gem。



我试过了:

  sudo gem install fakes3 
错误:执行gem时(Errno :: EPERM)
不允许操作 - / usr / bin / fakes3

然后我尝试了cocoapods的方式。它适用于cocoapods,但不适用于fakes3。

  mkdir -p $ HOME / Software / ruby​​ 
export GEM_HOME = $首页/软件/红宝石
gem install cocoapods
[...]
1 gem已安装
gem install fakes3
错误:执行gem时...(Gem: :FilePermissionError)
您没有对/Library/Ruby/Gems/2.0.0目录的写入权限。


解决方案

免责声明: @theTinMan和其他Ruby开发人员在安装gems时经常指出不要使用 sudo 并指向诸如 RVM 。在开发Ruby时绝对是这样。然后,使用它。



然而,我们中的很多人只是想要一些二进制文件,而这些二进制文件恰好分配为宝石(例如 fakes3 cocoapods xcpretty ...)。我绝对不想管理一个单独的ruby。这里有更快的选择:



选项1:继续使用sudo



使用 sudo如果你希望这些工具能够全局安装,那么可能没问题。



问题在于这些二进制文件安装在 / usr / bin 中,这是自El Capitan以来的禁区。但是,您可以将它们安装到 / usr / local / bin 中。这就是自制安装它的东西,所以它可能已经存在。

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

Gems将被安装到 / usr / local / bin ,并且系统中的每个用户都可以在他们的 PATH
$ b

选项2:安装到您的主目录(不含sudo)



以下将安装〜/ .gem 中的宝石,并将二进制文件放在〜/ bin 中(然后将其添加到)。



pre $ gem install fakes3 --user-install -n〜/ bin



设为默认值



无论哪种方式,你可以将这些参数添加到你的〜/ .gemrc 中,所以你不必重读他们:

  gem:-n / usr / local / bin 

echogem:-n / usr / local / bin>> 〜/ .gemrc





  gem:--user-install -n〜/ bin 

echogem:--user-install -n〜/ bin>> 〜/ .gemrc



提示:)你也可以在 - no -document 跳过生成Ruby开发者文档。)


I am not able to install and run fakes3 gem on El Capitan Beta 5.

I tried:

sudo gem install fakes3
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/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.

解决方案

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.

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:

Option 1: Keep using sudo

Using sudo is probably fine if you want these tools to be installed globally.

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 will be installed into /usr/local/bin and every user on your system can use them if it's in their PATH.

Option 2: Install in your home directory (without sudo)

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

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

i.e. echo "gem: -n/usr/local/bin" >> ~/.gemrc

or

gem: --user-install -n~/bin

i.e. echo "gem: --user-install -n~/bin" >> ~/.gemrc

(Tip: You can also throw in --no-document to skip generating Ruby developer documentation.)

这篇关于无法在OS X上安装宝石“El Capitan”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆