Cocoapods:无法连接到GitHub以更新CocoaPods / Specs规格repo

时间:2016-08-17 10:01:46

标签: ios xcode cocoapods cocoapods-1.0.1

运行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>'


无法找到解决此问题的方法,也无法运行该项目。

15 个答案:

答案 0 :(得分:411)

其中一个主要问题是&#34;弱加密标准被删除&#34; 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

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

$ 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

答案 1 :(得分:133)

最后设法通过删除./cocoapods/repos/master并运行pod install来解决此问题。

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

pod repo remove master
pod setup
pod install

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

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

答案 2 :(得分:51)

你可以试试这个:

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

但在我的情况下,我不得不:

  • 删除Podfile.lock然后

  • $pod install

答案 3 :(得分:42)

Max's中可以找到此线程中与Adem'sCocoaPods issue类似的其他解决方案:

ruby --version
which ruby

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

/usr/local/bin/ruby

应该使用{# set variable "current_category" to an empty value first #} {% for item in items %} {% if item.category != current_category %} {{ current_category = item.category }} {# <-- How to do that? #} <h1>{{ item.category }}</h1> {% endif %} <p>{{ item.name }}</p> {% endfor %}

<强>原因: 事实证明,在High Sierra之前的Github updated to only support TLS 1.2 on Feb 22nd.旧版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,这是一个很好的解决方案。

答案 4 :(得分:22)

我也遇到了同样的问题。在我的场景中,我在github上使用了cocoapods specs的镜像仓库(在其他地方托管)。当我更新specs repo时,它有效!

{
  "swagger": "2.0",
  ...
},
"host": "localhost:8080",
"basePath": "/swagger-item-jaxrs",
"schemes": [ "http" ],
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"paths": {
"/item/{cd}": {
  "get": {
    "description": "Returns an item based on the item code passed.",
    "operationId": "findItemById",
    "produces": [
      "application/json",
      "application/xml",
      "text/xml",
      "text/html"
    ],
    "parameters": [
      {
        "name": "cd",
        "in": "path",
        "description": "CD of item to fetch",
        "required": true,
        "type": "string"
      }
    ],
    "responses": {
      "200": {
        "description": "item response",
        "schema": {
          "$ref": "#/definitions/item"
        }
      },
      "default": {
        "description": "unexpected error",
        "schema": {
          "$ref": "#/definitions/errorModel"
        }
      }
    }
  }
}
},
"definitions": {
"item": {
  "type": "object",
  "required": [
    "cd",
    "name"
  ],
  "properties": {
    "cd": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "tag": {
      "type": "string"
    }
  }
},
"errorModel": {
  "type": "object",
  "required": [
    "code",
    "message"
  ],
  "properties": {
    "code": {
      "type": "integer",
      "format": "int32"
    },
    "message": {
      "type": "string"
    }
  }
}
}
}

答案 5 :(得分:14)

这就像魔术一样

$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

答案 6 :(得分:7)

只需更新cocoapods:sudo gem install cocoapods

答案 7 :(得分:7)

Adem的一个稍微简单的解决方案,它不使用rbenv:

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

最后,请确保您的PATH变量未设置为 /usr/local/bin之后的$PATH PATH中的~/.bash_profile导出应与以下内容类似:

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

答案 8 :(得分:6)

这对我有用:

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

答案 9 :(得分:2)

如果某人在Circle CI上遇到这些问题,我几乎要在这一天中挣扎。

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

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

从这个链接中你可以看到其中一个cocoapods核心贡献者说它很好: CocoaPods repo缓存大约每30分钟更新一次,这通常足以错过最后6次推送到Specs回购。

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

答案 10 :(得分:0)

我接下来在终端做了:

  1. brew install openssl

    如果你没有家酿:

    / usr / bin / ruby​​ -e&#34; $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;

    并重复第1页

  2. 导出路径=&#34; / usr / local / opt / openssl / bin:$ PATH&#34;

  3. openssl version

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

  4. pod update

答案 11 :(得分:0)

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

  

sudo gem uninstall nanaimo

然后

  

sudo gem install nanaimo

希望这会有所帮助。

答案 12 :(得分:0)

  1. 删除所有cocoapods包。 See here有关如何执行此操作的信息。

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

答案 13 :(得分:0)

对我来说,以下命令修复了问题

从mac中删除cocoapod

 sudo gem uninstall cocoapods

在mac上安装cocoapods

sudo gem install cocoapods

答案 14 :(得分:0)

如果任何人遇到任何类似的问题,其中遥控器过早挂起,请使用ssh代替克隆回购。

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

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

Follow their documentation here