20

I'm getting an error when I run 'gem install cocoapods' on OSX Mavericks.

$ gem install cocoapods
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - bad response backend read error 503 (https://rubygems.global.ssl.fastly.net/quick/Marshal.4.8/cocoapods-0.27.1.gemspec.rz)
ERROR:  Possible alternatives: cocoapods

Please note that I can download the cocoapods-0.27.1.gemspec.rz directly. I am running the latest version of XCode (5.0.1) and the latest version of its CLI tools. RVM is also configured to run the latest Ruby version (2.0.0p247)

Eternal Rubyist
  • 3,445
  • 4
  • 34
  • 51

9 Answers9

38

Sometimes ,the default source for gem, https://rubygems.org/, can't be accessed.

It should be removed by command:

gem sources -r https://rubygems.org/

And then new source should be added:

gem sources -a https://ruby.taobao.org/

Update the cache:

gem sources -u

You can check sources with:

gem sources

Finally , you can install cocoapods:

sudo gem install cocoapods
Neuron
  • 5,141
  • 5
  • 38
  • 59
taojigu
  • 457
  • 5
  • 5
  • 2
    $ gem sources -a http://ruby.taobao.org/ Error fetching http://ruby.taobao.org/: bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz) – sarfarazsajjad Oct 29 '15 at 07:51
  • Sorry , it should be "httpS://ruby.taobao.org/" – taojigu Nov 05 '15 at 10:20
  • 5
    Even with "httpS://ruby.taobao.org/" => Error fetching https://ruby.taobao.org/: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems-china.oss-cn-hangzhou.aliyuncs.com/specs.4.8.gz) – mythicalcoder Oct 18 '16 at 07:24
  • 1
    What is taoboa.org?? is that source reliable at all?? – d.ennis Apr 16 '20 at 10:50
  • 1
    I don't trust the source "taobao.org". How else can I solve this problem? – Ky - May 12 '20 at 21:52
28

Use the below mentioned steps to install Cocoapods in your machine, I solved the same issue with be below mentioned steps

1.Install command line tools using the command

xcode-select --install

2.Install Home brew by

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

3.Install Ruby using homebrew

brew install ruby

4.Check Ruby version

ruby -v

5.Install Ruby

gem source -a http://rubygems.org/

6.gem install cocoapods

sudo gem install cocoapods

or

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

7.Go to below folder

cd ~/.cocoapods/repos

8.Run the below command

git clone https://github.com/CocoaPods/Specs.git master

9.Go to the directory where Podfile is present and run

pod install
Cœur
  • 37,241
  • 25
  • 195
  • 267
Teja Swaroop
  • 1,139
  • 12
  • 18
12

It work for me:

Remove https source by command:

gem sources -r https://rubygems.org/

And then new http source should be added:

gem sources -a http://rubygems.org/

Update the cache:

gem sources -u
user3566863
  • 243
  • 1
  • 3
  • 7
3

Though I'm not sure what caused read error 503 I was able to work around the problem fairly easily by manually installing the cocoapods.gem.

If anyone else experiences similar problems (with cocoapods or any other gem), download the appropriate gem file (cocoapods-0.27.1.gem in my case) directly from RubyGems.org. Then run the gem install cocoapods-0.27.1.gem. The install command will scan the working directory first, thus detecting and installing the local gem package, cutting out the broken repository.

Eternal Rubyist
  • 3,445
  • 4
  • 34
  • 51
2

I found that just removing and re-adding rubygems seemed to work for me ( using the High Sierra on Mac) I prefer to use the official Rubygems repos

gem sources -r https://rubygems.org/
gem sources -a https://rubygems.org/
gem sources -u
sudo gem install cocoapods

I assume it must have been a glitch..

UKDataGeek
  • 6,338
  • 9
  • 46
  • 63
2

Just follow there steps and error is gone

1.Install command line tools using the command

xcode-select --install

2.Install Home brew by

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

3.Install cocapods using home-brew, it take care of everything

brew install cocoapods

4. Last step

pod setup
Sohaib Aslam
  • 1,245
  • 17
  • 27
1

This worked for me. Make sure to include sudo with install command.

gem sources -a http://rubygems.org/
gem sources -u
sudo gem install cocoapods
Hamza Waleed
  • 1,334
  • 10
  • 12
0

For me I had to change rubygems.org to be the gems url used at my company (which caches from rubygems.org).

I did sudo gem install cocoapods --source <my_company_url_for_gems>

Michael McKenna
  • 811
  • 1
  • 11
  • 24
-1

Let all http replace https,because the right cocoa pods's sources is https://ruby.taobao.org/

Jack.Gang
  • 1
  • 1