【问题标题】:Cocoapods: Failed to connect to GitHub to update the CocoaPods/Specs specs repoCocoapods:无法连接到 GitHub 以更新 CocoaPods/Specs 规范 repo
【发布时间】:2016-12-23 22:16:36
【问题描述】:

运行pod repo update时会产生如下错误:

Updating spec repo `master`
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down


使用 cocoapods 1.0.1

我也知道这一点:Master spec-repo rate limiting post‑mortem


在调用中添加 --verbose 标志会显示 ruby​​ 调用堆栈:

.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.0.1/lib/cocoapods-core/github.rb:100:in `modified_since_commit'
.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.0.1/lib/cocoapods-core/master_source.rb:32:in `requires_update?'
.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.0.1/lib/cocoapods-core/master_source.rb:14:in `update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:88:in `block (2 levels) in update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/user_interface.rb:63:in `section'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:87:in `block in update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:86:in `each'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:86:in `update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/command/repo/update.rb:23:in `run'
.rvm/gems/ruby-2.3.0/gems/claide-1.0.0/lib/claide/command.rb:334:in `run'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/command.rb:50:in `run'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/bin/pod:55:in `<top (required)>'
.rvm/gems/ruby-2.3.0/bin/pod:23:in `load'
.rvm/gems/ruby-2.3.0/bin/pod:23:in `<main>'
.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'


找不到解决此问题的任何方法,因此无法运行该项目。

【问题讨论】:

标签: ios xcode cocoapods cocoapods-1.0.1


【解决方案1】:

其中一个主要问题是 2018 年 2 月之后“弱加密标准被移除”。

请注意: https://github.com/blog/2507-weak-cryptographic-standards-removed

要解决这个问题,首先你需要更新 openssl,然后是 ruby​​,然后是 cocoapod。

$ which openssl
/usr/bin/openssl

$ openssl version
OpenSSL 0.9.8zh 14 Jan 2016

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

$ brew update

$ brew install openssl

$ brew upgrade openssl

`` If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

$ echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile

$ which openssl
/usr/local/opt/openssl/bin/openssl

$ openssl version
OpenSSL 1.0.2n  7 Dec 2017

$ brew install rbenv ruby-build

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
$ source ~/.bash_profile

$ rbenv install --list

Available versions:
  1.8.5-p52
  1.8.5-p113
  1.8.5-p114
  1.8.5-p115
  1.8.5-p231
  1.8.6
:
  2.5.0-rc1
  2.5.0
  2.5.1
  2.6.0-dev
:

$ rbenv install 2.5.1

$ rbenv versions
* system (set by /Users/username/.rbenv/version)
  2.5.1

$ ruby --version
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

$ rbenv global 2.5.1

$ rbenv versions
  system
* 2.5.1 (set by /Users/username/.rbenv/version)

$ ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]

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

$ which pod
/usr/local/bin/pod

$ pod --version
1.5.3

现在可以了

$ pod update

来源链接:https://qiita.com/satoshi-iwaki/items/ed2c267127dcc80baa21

【讨论】:

  • 应该是export PATH="$HOME/.rbenv/shims:$PATH" 而不是export PATH="$HOME/.rbenv/bin:$PATH"
  • 安装 ruby​​ 2.1.0 版是否有原因?为什么不是最新的?
  • 我按照此建议进行按键操作,以及此线程中的所有其他建议答案......无济于事。我已经把 Cocoapods repo 吹走了很多次了。有什么长镜头或疯狂的想法吗?
  • 您应该使用较新的 Ruby 版本,因为:“警告:ruby-2.1.0 已过期,现在不受支持。它不再接收错误修复或关键安全更新。”
  • 在运行 pod repo update 之前还必须执行 rm -rf ~/.cocoapods/
【解决方案2】:
  • 更新 ruby​​ 和 cocoapods。
  • 检查 cocoapods 环境中的 ruby​​ 版本。

使用

pod env

rbenv global x.x.x
ruby -v

更改 ruby​​ 版本。如果不工作,看这个rbenv not changing ruby version

检查 cocoapods 环境中的 ruby​​ 版本。如果不改变,

which pod

确保您的 pod 路径是 /usr/local/bin/pod,如果不是的话

export PATH=/usr/local/bin:$PATH

【讨论】:

    【解决方案3】:

    终于设法通过删除./cocoapods/repos/master并运行pod install来解决它。

    更正式的解决方案可能是这样的:

    pod repo remove master
    pod setup
    pod install
    

    如果pod install 在执行前两个步骤后失败,您可能需要删除您的Podfile.lock

    为什么它最初无法连接到 Github 是我无法理解的。

    【讨论】:

    • 更改 ssh 密钥后发生在我身上。作为可能的原因之一。
    • 我完成了所有 3 个步骤,但仍然显示 [!] 无法连接到 GitHub 以更新 CocoaPods/Specs 规格存储库 - 请检查您是否离线,或者 GitHub 已关闭
    • 删除“Podfile.lock”文件然后执行“pod install”对我有用!谢谢
    • ~/.cocoapods 不是./cocoapods
    • 这对我有用,为我要删除的用户更改“主人”
    【解决方案4】:

    任何遇到远程过早挂断的类似问题的人,请改用ssh 克隆存储库。

    git clone git@github.com:CocoaPods/Specs.git master。

    要使用 SSH 克隆 GitHub 存储库,您需要拥有一个 GitHub 帐户并拥有与之关联的 SSH 密钥。

    Follow their documentation here.

    【讨论】:

      【解决方案5】:

      对我来说,以下命令解决了这个问题

      从 mac 中移除 cocoapods

       sudo gem uninstall cocoapods
      

      在 mac 上安装 cocoapods

      sudo gem install cocoapods
      

      【讨论】:

        【解决方案6】:
        1. 删除所有 cocoapods 包。 See here 了解如何执行此操作的信息。

        2. 然后重新安装 cocoapods。 $ sudo gem install cocoapods

        【讨论】:

          【解决方案7】:

          我也遇到了同样的问题。 我只通过从终端访问两个命令来解决它。

          sudo gem 卸载 nanaimo

          然后

          sudo gem 安装 nanaimo

          希望它会有所帮助。

          【讨论】:

            【解决方案8】:

            我在终端做了下一个:

            1. 酿造安装openssl

              如果您没有自制啤酒:

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

              然后重复第 1 页

            2. export PATH="/usr/local/opt/openssl/bin:$PATH"

            3. openssl 版本

              输出:OpenSSL 1.0.2n 2017 年 12 月 7 日

            4. pod 更新

            【讨论】:

              【解决方案9】:

              这对我有用:

              1. 删除Podfile.lock
              2. 运行pod install

              【讨论】:

                【解决方案10】:

                另一个类似Max'sAdem's的解决方案可以在CocoaPods issue找到:

                brew install ruby
                sudo gem install cocoapods
                

                Verify that you're using the latest and correct Ruby with:

                ruby --version
                which ruby
                

                应该使用/usr/local/bin/ruby

                原因: 事实证明,Github updated to only support TLS 1.2 on Feb 22nd. High Sierra 之前的旧版 MacOS 预装了 Ruby 2.0。此版本使用 OpenSSL 0.9.8 其中"will fail with servers supporting only TLS 1.2."

                更新到最新的 Ruby (2.5) 和最新的 CocoaPods (1.4) 为我解决了这个问题,而无需对 openssl 做任何事情(Ruby 更新 openssl)。如果您还不想更新到 High Sierra,这是一个很好的解决方案。

                【讨论】:

                • 其他解决方案均无效,但确实有效。更新到最新的 Ruby 和最新的 CocoaPods。谢谢。
                • 这并没有为我解决问题,但我投票支持背景解释。
                • 我在推送 podspec 时遇到了这个问题。这真的很有帮助!
                • 重要细节:我通过 brew 安装了 CocoaPods。在那种情况下,升级 Ruby 和 openssl 是不够的。我必须卸载 CocoaPods,然后通过 gem 重新安装它,如this answer所示。
                【解决方案11】:

                如果有人在 Circle CI 上遇到这些问题,我几乎为此苦苦挣扎了一天。

                最后我认为最好的方法是使用他们提供的解决方案从他们的服务器下载。

                curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
                

                从这个链接你可以看到 cocoapods 的核心贡献者之一说这很好: CocoaPods 存储库缓存大约每 30 分钟更新一次,这通常足够频繁,只会错过对 Specs 存储库的最后 6 次推送。

                https://discuss.circleci.com/t/best-practice-for-use-of-cached-cocoapods-specs/18897/2

                【讨论】:

                  【解决方案12】:

                  你可以试试这个:

                  $sudo rm -fr ~/.cocoapods/repos/master
                  $pod setup
                  $pod install
                  

                  但就我而言,我必须:

                  • 删除 Podfile.lock 然后

                  • $pod install

                  【讨论】:

                    【解决方案13】:

                    来自 Adem 的不使用 rbenv 的稍微简单的解决方案:

                    brew install openssl
                    brew upgrade openssl
                    brew install ruby
                    brew link --overwrite ruby
                    

                    最后,确保您没有将PATH 变量设置为/usr/local/bin 之后 $PATH。您在~/.bash_profile 中的PATH 导出应该类似于以下内容:

                    export PATH=/usr/local/bin:$PATH
                    

                    【讨论】:

                    • 这对我来说也足够了。请注意,您仍然需要通过运行 gem install cocoapods 重新安装 cocoapods,因为每个 ruby​​ 都有自己的 gem 位置。顺便说一句,没有必要运行 brew install openssl 步骤,因为它是 ruby​​ 的依赖项。
                    • 这对我很有帮助,谢谢!虽然我在更改 ~/.bash_profile 文件后不得不重新启动终端。
                    【解决方案14】:

                    只需更新 cocoapods:sudo gem install cocoapods

                    【讨论】:

                      【解决方案15】:

                      我也遇到了同样的问题。在我的场景中,我使用了 github 上 cocoapods 规格的镜像仓库(托管在其他地方)。当我更新规范回购时,它起作用了!

                      cd ~/.cocoapods/repos/master
                      git pull
                      

                      【讨论】:

                      • 我也遇到了离线/github关闭错误,这就是有效的。我有点犹豫是否要卸载 pod。
                      • 这个答案实际上对我有用。我花了2个多小时。非常感谢。
                      • 这个答案实际上是通过一个解决方案解决了这个问题,而不是通过删除强制执行 git clone 的文件夹来解决这个问题。
                      【解决方案16】:

                      这就像魔术一样工作

                      $sudo rm -fr ~/.cocoapods/repos/master
                      $pod setup
                      $pod install
                      

                      否则

                      $pod setup
                      Ctrl +C
                      cd ~/.cocoapods/repos 
                      $git clone --depth 1 https://github.com/CocoaPods/Specs.git master
                      

                      【讨论】:

                        猜你喜欢
                        • 2015-09-11
                        • 2014-11-12
                        • 1970-01-01
                        • 1970-01-01
                        • 1970-01-01
                        • 2017-07-06
                        • 1970-01-01
                        • 1970-01-01
                        • 1970-01-01
                        相关资源
                        最近更新 更多