如何让Cocoapods与RVM一起运行? [英] How to get Cocoapods running with RVM?

查看:184
本文介绍了如何让Cocoapods与RVM一起运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不幸的是,我最近在我的Mac上将系统Ruby升级到2.3。由于我必须将Cocoapods 0.39用于特定项目不正确工作,我会喜欢使用旧版本的Ruby。为此,我安装了rvm,然后切换到ruby-2.2-head:

 > \curl -sSL https://get.rvm.io | bash -s stable --ruby 
> rvm install 2.2-head
> rvm use 2.2-head --default

这很好。然后我尝试安装Cocoapods,并得到了一般的错误信息:

 > rvmsudo gem install cocoapods 
$ b $警告:无法检查`/ etc / sudoers`是否为`secure_path`,通过`/ usr / bin / env`回退,这会破坏`/ etc / sudoers`。运行:

export rvmsudo_secure_path = 1

以避免该警告,将其放入shell初始化文件中以使其持久化。

如果`/ etc / sudoers`中没有'secure_path`。运行:

export rvmsudo_secure_path = 0

我通过选择第二个选项。然后我检查了Cocoapods,并得到了一个奇妙的错误信息:

 > pod --version 

/Users/bastian/.rvm/rubies/ruby-2.2-head/lib/ruby/site_ruby/2.2.0/rubygems.rb:250:in`find_spec_for_exe':can从/Users/bastian/.rvm/rubies-2.2-head/lib/ruby/site_ruby/2.2.0/找到gem cocoapods(> = 0.a)(Gem :: GemNotFoundException)
rubygems.rb:278:在`activate_bin_path'
from / Users / bastian / bin / pod:22:in< main>'

此外,Cocoapods没有使用以下命令列出:

 >宝石名单

***本地GEMS ***

bigdecimal(1.2.6)
io-console(0.4.3)
json( 1.8.1)
psych(2.0.8)
rake(10.4.2)
rdoc(4.2.0)

此外,Cocoapods似乎被安装到错误的目录中:

 > ;其中pod 
/ Users / bastian / bin / pod

所以如果我切换回系统Ruby, pod --version 命令返回 0.39.0



我想不知何故Cocoapods没有与RVM Ruby一起安装,而是与系统版本一起安装。我做错了什么?

解决方案

借助这个Stackoverflow文章我能解决这个问题。我不知道为什么,但是从 .gemrc 删除单个条目 - user 为我解决了这个问题。由于该文件只包含这一行,因此我只是将其重命名并重新安装了Cocoapods:

 > mv〜/ .gemrc〜/ .gemrc_backup 
> gem install cocoapods`

现在Cocoapods再次运行,因为它位于正确的路径:

 > / p 
/Users/bastian/.rvm/gems/ruby-2.2-head/bin/pod


Unfortunately, I recently upgraded the system Ruby to 2.3 on my Mac. Since I have to use Cocoapods 0.39 for a specific project which does not properly work, I would like to use an older version of Ruby. For this purpose, I installed rvm and then switched to ruby-2.2-head:

> \curl -sSL https://get.rvm.io | bash -s stable --ruby
> rvm install 2.2-head
> rvm use 2.2-head --default

This worked fine. Then I tried to install Cocoapods and got the usual error message:

> rvmsudo gem install cocoapods

Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. Run:

    export rvmsudo_secure_path=1

to avoid the warning, put it in shell initialization file to make it persistent.

In case there is no `secure_path` in `/etc/sudoers`. Run:

    export rvmsudo_secure_path=0 

which I silenced by chosing the second option. Then I checked Cocoapods and got a fantastic error message:

> pod --version

/Users/bastian/.rvm/rubies/ruby-2.2-head/lib/ruby/site_ruby/2.2.0/rubygems.rb:250:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
    from /Users/bastian/.rvm/rubies/ruby-2.2-head/lib/ruby/site_ruby/2.2.0/rubygems.rb:278:in `activate_bin_path'
    from /Users/bastian/bin/pod:22:in `<main>'

Furthermore, Cocoapods is not listed with the following command:

> gem list

*** LOCAL GEMS ***

bigdecimal (1.2.6)
io-console (0.4.3)
json (1.8.1)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)

Furthermore, Cocoapods seems to be installed into the wrong directory:

> which pod
/Users/bastian/bin/pod

So if I switch back to the system Ruby, the pod --version command returns 0.39.0.

I guess that somehow Cocoapods was not installed with the RVM Ruby but rather with the system version. What did I do wrong?

解决方案

With the help of this Stackoverflow post I was able to solve the problem. I don't know why but the removal of the single entry --user from .gemrc solved this problem for me. Since the file only contained this one line I just renamed it and reinstalled Cocoapods:

 > mv ~/.gemrc ~/.gemrc_backup
 > gem install cocoapods`

Now Cocoapods is working again as it resides at the correct path:

> which pod
/Users/bastian/.rvm/gems/ruby-2.2-head/bin/pod

这篇关于如何让Cocoapods与RVM一起运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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