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

16

141

When running pod repo update the following error is generated:

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

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


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

.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.

Copperhead answered 17/8, 2016 at 10:1 Comment(1)
Refer to github.com/CocoaPods/CocoaPods/issues/…, it's related to older Ruby versionMetabolism
S
421

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

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

To solve this, first you need to update openssl, then ruby, then 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

Spinescent answered 24/2, 2018 at 10:56 Comment(12)
it should be export PATH="$HOME/.rbenv/shims:$PATH" and not export PATH="$HOME/.rbenv/bin:$PATH"Poland
Is there are reason why you're installing version 2.1.0 of ruby? Why not the latest?Waitress
there is not particular reason. newer version would probably work, but 2.1.0 seems working. so, I dont want to risk higher versionSpinescent
I followed this advice to the keystroke, along with every other suggested answer in this thread... to no avail. I've blown away the Cocoapods repo so many times. Any long shots or crazy ideas out there?Fetish
You should use a newer Ruby version because of this: "WARNING: ruby-2.1.0 is past its end of life and is now unsupported. It no longer receives bug fixes or critical security updates."Spavined
I used ruby 2.2.9 and it worked, although I get a warning about nearing end of life.Kinny
Also had to do rm -rf ~/.cocoapods/ before running pod repo updatePitiable
@Spinescent i am getting this error "Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools" can you help me ? Full Error : paste.ubuntu.com/p/Y8Z99NXmVzAlfalfa
Without restarting also it works for me, thanks to @SpinescentZwart
Note that Podfile version 1.5.0.beta.1 doesn't work for me. Execute this command sudo gem uninstall cocoapods and select 1.5.0.beta.1 to remove this versionMcgrath
I'm getting this error :- $ rbenv install 2.5.0 ruby-build: use openssl from homebrew Downloading ruby-2.5.0.tar.bz2... -> cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.bz2 error: failed to download ruby-2.5.0.tar.bz2 BUILD FAILED (OS X 10.12.6 using ruby-build 20180329)Sisto
install cocoapods it should be : sudo gem install cocoapods -n /usr/local/binGalloon
C
141

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

The more formal solution would probably go like this:

pod repo remove master
pod setup
pod install

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

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

Copperhead answered 17/8, 2016 at 12:4 Comment(5)
Happened to me after changing ssh keys. As one of the possible reasons.Aerodyne
I did all the 3 steps but still it shows [!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is downFit
deleting "Podfile.lock" file and then executing "pod install" worked for me! ThanksMcmaster
it's ~/.cocoapods not ./cocoapodsTatman
That works for me, changing 'master' for the user whom I want to deleteFinnie
S
52

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

Suspensor answered 12/4, 2017 at 1:32 Comment(0)
G
43

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

brew install ruby
sudo gem install cocoapods

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

ruby --version
which ruby

Should be using /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."

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.

Granny answered 27/2, 2018 at 20:2 Comment(2)
This didn't fix it for me, but I voted up for the background explanation.Hawserlaid
Important detail: I had CocoaPods installed via brew. In that case upgrading Ruby and openssl wasn't sufficient. I had to uninstall CocoaPods and then reinstall it via gem as shown in this answer.Linneman
P
22

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!

cd ~/.cocoapods/repos/master
git pull
Plaza answered 1/6, 2017 at 17:1 Comment(1)
I was getting the offline/github down error thing as well and this is what worked. I was a little hesitant to uninstall pods.Malamud
P
15

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
Prang answered 9/2, 2017 at 11:50 Comment(0)
H
8

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

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

Finally, make sure you don't have your PATH variable set to have /usr/local/bin after $PATH. Your PATH export in ~/.bash_profile should look similar to this:

export PATH=/usr/local/bin:$PATH
Headstock answered 26/2, 2018 at 20:17 Comment(1)
This what also was enough for me. Note that you still need to re-install cocoapods by running gem install cocoapods as each ruby has its own gem location. BTW, there's no need to run the brew install openssl step as it's a dependency of ruby anyway.Bathelda
B
8

This worked for me:

  1. Remove Podfile.lock
  2. Run pod install
Broads answered 14/3, 2018 at 13:14 Comment(0)
A
7

Just update cocoapods: sudo gem install cocoapods

Ammons answered 26/2, 2018 at 16:25 Comment(0)
R
2

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

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.

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

Rodas answered 27/2, 2018 at 9:0 Comment(0)
I
0

I did next in Terminal:

  1. brew install openssl

    if you don't have home brew:

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

    and repeat p.1

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

  3. openssl version

    Output:OpenSSL 1.0.2n 7 Dec 2017

  4. pod update

Intermeddle answered 15/3, 2018 at 11:24 Comment(0)
E
0

I was also facing the same problem. I solved it only by accessing two commands from terminal.

sudo gem uninstall nanaimo

and then

sudo gem install nanaimo

Hope so it will help.

Excommunicate answered 20/3, 2018 at 4:32 Comment(0)
L
0
  1. Remove all of cocoapods package. See here for information on how to do this.

  2. Then reinstall cocoapods. $ sudo gem install cocoapods

Landin answered 2/4, 2018 at 15:50 Comment(0)
W
0

For me the below commands fixed the issue

Removing cocoapods from mac

 sudo gem uninstall cocoapods

Installing cocoapods on mac

sudo gem install cocoapods
Wrac answered 6/4, 2018 at 10:19 Comment(0)
N
0

Anyone facing any similar issue where the remote hangs-up prematurely, use ssh to clone the repo instead.

git clone [email protected]:CocoaPods/Specs.git master.

In order to use SSH to clone a GitHub repo, you need to have a GitHub account and have your SSH keys associated with it.

Follow their documentation here.

Nernst answered 11/5, 2018 at 16:28 Comment(0)
S
0
  • update ruby and cocoapods.
  • check ruby version in the cocoapods env.

use

pod env

enter image description here

rbenv global x.x.x
ruby -v

change ruby version. If not working, watch this rbenv not changing ruby version

check ruby version in the cocoapods env. If not changed,

which pod

make sure your pod path is /usr/local/bin/pod,if not

export PATH=/usr/local/bin:$PATH
Survive answered 17/1, 2020 at 3:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.