ios Cocoapods:无法连接到 GitHub 以更新 CocoaPods/Specs 规格存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38993527/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:56:17  来源:igfitidea点击:

Cocoapods: Failed to connect to GitHub to update the CocoaPods/Specs specs repo

iosxcodecocoapodscocoapods-1.0.1

提问by Ivan M.

When running pod repo updatethe following error is generated:

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


Using cocoapods 1.0.1


使用 cocoapods 1.0.1

I'm also aware of this: Master spec-repo rate limiting post?mortem.

我也知道这一点:Master spec-repo rate limit post?mortem


Adding --verbose flag to the call shows the ruby call stack:


在调用中添加 --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>'



Can't find any way to workaround this and cannot run the project.

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

回答by Adem

One of the major issue is "weak cryptographic standards removed" after 2018 February.

主要问题之一是 2018 年 2 月之后“删除了弱加密标准”。

Here a note: https://github.com/blog/2507-weak-cryptographic-standards-removed

这里有一个说明:https: //github.com/blog/2507-weak-cryptographic-standards-removed

To solve this, first you need to update openssl, then ruby, then cocoapod.

要解决这个问题,首先需要更新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

now, you can do

现在,你可以做

$ pod update

source link: https://qiita.com/satoshi-iwaki/items/ed2c267127dcc80baa21

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

回答by Ivan M.

Finally managed to solve it by deleting ./cocoapods/repos/masterand running pod install.

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

The more formal solution would probably go like this:

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

pod repo remove master
pod setup
pod install

If pod installfails after performing the first two steps, you may need to delete your Podfile.lock.

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

Why it initially failed to connect to Github is beyond me.

最初无法连接到 Github 的原因超出了我的理解。

回答by Mars

You can try this:

你可以试试这个:

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

but in my case I had to:

但就我而言,我不得不:

  • delete the Podfile.lock and then

  • $pod install

  • 删除 Podfile.lock 然后

  • $pod install

回答by Mykaelos

A another solution similar to Max'sand Adem'sin this thread is found in a CocoaPods issue:

CocoaPods 问题中找到了另一个类似于MaxAdem在此线程中的解决方案

brew install ruby
sudo gem install cocoapods

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

通过以下方式验证您使用的是最新且正确的 Ruby:

ruby --version
which ruby

Should be using /usr/local/bin/ruby

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

Reason:It turns out that Github updated to only support TLS 1.2 on Feb 22nd.Older versions of MacOS before High Sierra come preinstalled with Ruby 2.0. This version uses OpenSSL 0.9.8 which "will fail with servers supporting only TLS 1.2."

原因:事实证明,Github 在 2 月 22 日更新为仅支持 TLS 1.2。High Sierra 之前的旧版 MacOS 预装了 Ruby 2.0。此版本使用 OpenSSL 0.9.8,它“在服务器仅支持 TLS 1.2 时会失败”。

Updating to the latest Ruby (2.5) and latest CocoaPods (1.4) fixed this for me without having to do anything with openssl (Ruby updates openssl). This is a good solution if you don't want to update to High Sierra just yet.

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

回答by noveleven

I also encountered the same issue. In my scene, i used a mirror repo (hosted elsewhere) of cocoapods specs on github. When i updated the specs repo, it worked!

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

cd ~/.cocoapods/repos/master
git pull

回答by Nagarjun

This worked like magic

这就像魔术一样

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

Otherwise

除此以外

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

回答by Hamed

This worked for me:

这对我有用:

  1. Remove Podfile.lock
  2. Run pod install
  1. 消除 Podfile.lock
  2. pod install

回答by Grifas

Just update cocoapods: sudo gem install cocoapods

只需更新 cocoapods: sudo gem install cocoapods

回答by Max

A slightly simpler solution from Adem's that doesn't use rbenv:

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

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

Finally, make sure you don't have your PATHvariable set to have /usr/local/binafter$PATH. Your PATHexport in ~/.bash_profileshould look similar to this:

最后,确保您没有将PATH变量设置为/usr/local/binafter$PATH。您的PATH导出~/.bash_profile应与此类似:

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

回答by Kristaps Grinbergs

If someone has these issues on Circle CI I was struggling with this for a day almost.

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

In the end I think the best way is to use their provided solution to download from their servers.

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

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

From this link you can see that one of the cocoapods core contributor says that it's fine: The CocoaPods repo cache is updated roughly every 30 mins, which is usually frequent enough to only miss the last 6 pushes to the Specs repo.

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

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

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