Unable to install 'cocoapods' gem from rubygems.org (bad response backend read error)

本秂侑毒 提交于 2019-11-29 00:58:27

问题


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)


回答1:


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



回答2:


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



回答3:


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



回答4:


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.




回答5:


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




回答6:


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



回答7:


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



来源:https://stackoverflow.com/questions/19612185/unable-to-install-cocoapods-gem-from-rubygems-org-bad-response-backend-read-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!