无法从 ruby​​gems.org 安装“cocoapods” gem(错误响应后端读取错误)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19612185/
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-09-06 06:15:44  来源:igfitidea点击:

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

rubyxcodegemcocoapods

提问by depthfirstdesigner

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

在 OSX Mavericks 上运行“gem install cocoapods”时出现错误。

$ 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)

请注意,我可以直接下载 cocoapods-0.27.1.gemspec.rz。我正在运行最新版本的 XCode (5.0.1) 及其 CLI 工具的最新版本。RVM 还配置为运行最新的 Ruby 版本 (2.0.0p247)

采纳答案by depthfirstdesigner

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

虽然我不确定是什么原因导致 read error 503我能够通过手动安装 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.

如果其他人遇到类似问题(使用 cocoapods 或任何其他 gem),请直接从 RubyGems.org 下载适当的 gem 文件(在我的例子中为 cocoapods-0.27.1.gem)。然后运行gem install cocoapods-0.27.1.gem. install 命令会首先扫描工作目录,从而检测并安装本地 gem 包,切出损坏的存储库。

回答by taojigu

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

有时,https://rubygems.org/无法访问gem 的默认源。

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:

最后,您可以安装cocoapods

sudo gem install cocoapods

回答by Teja Swaroop

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

使用下面提到的步骤在你的机器上安装 Cocoapods,我用下面提到的步骤解决了同样的问题

1.Install command line tools using the command

1.使用命令安装命令行工具

xcode-select --install

2.Install Home brew by

2.安装Home brew

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

3.Install Ruby using homebrew

3.使用自制软件安装Ruby

brew install ruby

4.Check Ruby version

4.检查Ruby版本

ruby -v

5.Install Ruby

5.安装红宝石

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

6.gem install cocoapods

6.gem 安装 cocoapods

sudo gem install cocoapods

or

或者

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

7.Go to below folder

7.转到下面的文件夹

cd ~/.cocoapods/repos

8.Run the below command

8.运行以下命令

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

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

9.进入Podfile所在目录,运行

pod install

回答by user3566863

It work for me:

它对我有用:

Remove httpssource by command:

通过命令删除https源:

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

And then new httpsource should be added:

然后应该添加新的http源:

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

Update the cache:

更新缓存:

gem sources -u

回答by UKDataGeek

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

我发现只是删除和重新添加 ruby​​gems 似乎对我有用(在 Mac 上使用 High Sierra)我更喜欢使用官方的 Rubygems 存储库

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

我想这一定是一个小故障..

回答by Hamza Waleed

This worked for me. Make sure to include sudowith install command.

这对我有用。确保包含sudo安装命令。

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

回答by Sohaib Aslam

Just follow there steps and error is gone

只需按照那里的步骤,错误就消失了

1.Install command line tools using the command

1.使用命令安装命令行工具

xcode-select --install

2.Install Home brew by

2.安装Home brew

/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

3.使用home-brew安装cocapods,它会处理一切

brew install cocoapods

4. Last step

4. 最后一步

pod setup

回答by Michael McKenna

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

对我来说,我不得不将 ruby​​gems.org 更改为我公司使用的 gems url(从 ruby​​gems.org 缓存)。

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

我做了 sudo gem install cocoapods --source <my_company_url_for_gems>

回答by Hyman.Gang

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

让所有的 http 替换 https,因为正确的可可豆的来源是https://ruby.taobao.org/