在OS X上安装Cocoapods El Capitan错误

时间:2016-04-04 12:06:43

标签: ios rubygems cocoapods osx-elcapitan

首先。由于iOS 9.3,我更新了El Capitan,仅在xCode 7.3中支持它。

更新后,我发现pod命令不起作用。 我执行了:

sudo gem install cocoapods
ERROR:  Error installing cocoapods:
    activesupport requires Ruby version >= 2.2.2.

所以我的问题是我无法安装cocoapods。我对宝石和红宝石的东西一无所知。有人知道如何处理这个问题吗?

我使用El Capitan 10.11.4获得了第二个OS X,一切正常,所以我不知道这个问题来自哪里。

更新日期:2016年4月5日

我在终端上执行了几个命令以获取更多信息:

Kapucha:~ kapucha$ which ruby
/usr/bin/ruby
Kapucha:~ kapucha$ which gem
/usr/bin/gem
Kapucha:~ kapucha$ which brew
/usr/local/bin/brew
Kapucha:~ kapucha$ which rvm
/Users/kapucha/.rvm/bin/rvm

版本:

Kapucha:~ kapucha$ ruby --version
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
Kapucha:~ kapucha$ gem --version
2.2.2
Kapucha:~ kapucha$ brew --version
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir': Permission denied - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15 (Errno::EACCES)
Kapucha:~ kapucha$ rvm --version
rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

.bash_profile文件和.profile

Kapucha:~ kapucha$ cat .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
. ~/.bashrc
source ~/.profile

Kapucha:~ kapucha$ cat .profile
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

rvm list和rvm info

Kapucha:local kapucha$ rvm list

rvm rubies


# No rvm rubies installed yet. Try 'rvm help install'.

Kapucha:local kapucha$ rvm info

system:

  system:
    uname:       "Darwin Kapucha.local 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64"
    system:      "osx/10.11/x86_64"
    bash:        "/bin/bash => GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)"
    zsh:         "/bin/zsh => zsh 5.0.8 (x86_64-apple-darwin15.0)"

  rvm:
    version:      "rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "18 hours 23 minutes 25 seconds ago"
    path:         "/Users/kapucha/.rvm"

  homes:
    gem:          "not set"
    ruby:         "not set"

  binaries:
    ruby:         "/usr/bin/ruby"
    irb:          "/usr/bin/irb"
    gem:          "/usr/bin/gem"
    rake:         "/usr/bin/rake"

  environment:
    PATH:         "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/filipkotwicki/dev/tools/android-sdk-macosx/platform-tools:~/bin:/opt/X11/bin:/usr/local/git/bin:/Users/kapucha/.rvm/bin:/Users/kapucha/.rvm/bin"
    GEM_HOME:     ""
    GEM_PATH:     ""
    MY_RUBY_HOME: ""
    IRBRC:        ""
    RUBYOPT:      ""
    gemset:       ""

当我试图用rvm

安装Ruby时
Kapucha:local kapucha$ rvm install 2.2.2
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/osx/10.11/x86_64/ruby-2.2.2.tar.bz2
Checking requirements for osx.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir': Permission denied - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15 (Errno::EACCES)
...
ERROR: '/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.

尝试酿造医生的结果相同:

Kapucha:local kapucha$ brew doctor
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir': Permission denied - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15 (Errno::EACCES)

8 个答案:

答案 0 :(得分:93)

这是一个比其他更简单的解决方案安装自制/使用rvm&#39;建议 - 首先安装旧版本的&#39; activesupport&#39; (它与ruby 2.0和cocoapods兼容)然后安装cocoapods。

sudo gem install activesupport -v 4.2.6
sudo gem install cocoapods

以下是建议this解决方法的cocoapods错误报告。

答案 1 :(得分:5)

  1. 使用此命令安装Homebrew

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  2. 现在我们安装了Homebrew,我们可以用它来安装Ruby。 我们将使用rbenv来安装和管理我们的Ruby版本。 为此,请在终端中运行以下命令:

    brew install rbenv ruby-build
    
  3. 现在安装ruby

    echo 'if which rbenv > /dev/null;
    
    then eval "$(rbenv init -)";
    
    fi' >> ~/.bash_profilesource ~/.bash_profile
    
    rbenv install 2.3.1
    
    rbenv global 2.3.1 
    
    ruby -v
    
  4. 安装cocoapods

    sudo gem install cocoapods
    

答案 2 :(得分:3)

最后我解决了这个问题。

目标是安装cocoapods,但是我需要ruby&gt; = 2.2.2。

由于错误,

安装rvm install 2.2未完成:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir': Permission denied - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15 (Errno::EACCES)

运行brew会导致同样的错误。所以我决定先修好brew。它通过卸载并再次安装来解决。这并不容易。卸载脚本不起作用,因为.git中没有/usr/local文件夹。

我决定提供.git文件夹。

我将git clone https://github.com/Homebrew/homebrew.git克隆到某个临时文件夹然后cp -r .git /usr/local/,所以最后我的brew文件夹.git中有/usr/local个文件夹。在此之后,我能够Uninstall and Install fresh brew on El Capitan。请看这个链接的第2部分。

根据this/usr/local中使用El Capitan的工作brew和固定权限,我可以使用rvm安装ruby:

rvm install 2.2
rvm use 2.2

最后为El Capitan安装cocapods:

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

答案 3 :(得分:3)

我使用此命令并正确工作: -

sudo gem install activesupport -v 4.2.6
 sudo gem install cocoapods

答案 4 :(得分:0)

activesupport gem Cocoapods depends on要求Ruby版本大于2.2.2(请参阅here)。

您使用的是哪个版本的Ruby(类型ruby --version)?也许您的第二个OS X系统正在使用系统Ruby版本(您可以通过键入which ruby来检查它。)

可能您需要安装较新版本的Ruby(例如2.2.3)。我建议RVM在您的计算机上安装和管理Ruby版本。

答案 5 :(得分:0)

使用以下命令安装 homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

然后在不使用sudo

的情况下安装 cocoapods

gem install cocoapods

答案 6 :(得分:0)

请从this链接安装最新版本的Ruby和RVM(Ruby版本管理器)。

然后运行“sudo install cocoapods

答案 7 :(得分:0)

El Capitan 10.11.3

1)$ sudo gem install activesupport -v 4.2.6

2)$ sudo gem install -n / usr / local / bin cocoapods