简体   繁体   English

捆绑安装无法从 https://rubygems.org/ 获取规范

[英]Bundle Install could not fetch specs from https://rubygems.org/

I'm attempting to follow the Hartl Rails Tutorial, and having trouble with the bundler gem.我正在尝试遵循 Hartl Rails 教程,但在使用 bundler gem 时遇到了问题。

When using the commands 'bundle install' or 'bundle update' I get the following output:使用命令“捆绑安装”或“捆绑更新”时,我得到以下 output:

Fetching source index from https://rubygems.org/https://rubygems.org/获取源索引

Could not fetch specs from https://rubygems.org/无法从https://rubygems.org/获取规格

I've searched for this output, but did not find many related issues online.我搜索过这个output,但是网上没有找到很多相关问题。

Maybe I have another gem that is interrupting bundler?也许我有另一个打断捆绑器的宝石? I have little experience with rails at this point.在这一点上,我对 Rails 几乎没有经验。

    source 'https://rubygems.org'

gem 'rails', '3.2.12'

group :development do
  gem 'sqlite3', '1.3.5'
end


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.5'
  gem 'coffee-rails', '3.2.2'

  gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.2'

The solution for me was two parts: I changed https to http, and that temporarily solved the issue.我的解决方案是两个部分:我将 https 更改为 http,这暂时解决了问题。 The second issue was that I think I had a bad install of ruby 2.0.0 even though I was using a fresh install of ruby 1.9.3.第二个问题是,即使我使用的是全新安装的 ruby 1.9.3,我认为我的 ruby 2.0.0 安装错误。 So I reinstalled ruby 2.0.0, and I could use bundle install with https.所以我重新安装了 ruby 2.0.0,我可以将捆绑安装与 https 一起使用。

Just in case none of the above satisfies the next intrepid explorer, I thought I'd drop here that after I spent 4 hours on this doing variants of the search that landed me here, I finally discovering that IPV6 was the culprit, after finding this specific thread on help.rubygems.org .以防万一以上都不能满足下一个勇敢的探索者,我想我会放弃这里,在我花了 4 个小时做了这个让我来到这里的搜索变体之后,我终于发现 IPV6 是罪魁祸首,在找到这个之后help.rubygems.org 上的特定线程 Solution?解决方案? this (Fedora, Linux):这个(Fedora,Linux):

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

set up a shell script to flip IPV6 on and off so I could run a command without it, and now everything runs peachy.设置一个 shell 脚本来打开和关闭 IPV6,这样我就可以在没有它的情况下运行命令,现在一切都运行良好。

I had the same issue.我遇到过同样的问题。 The only working solution I found was to force http instead of https in Gemfile:我发现的唯一可行的解​​决方案是在 Gemfile 中强制使用 http 而不是 https:

source 'http://rubygems.org'

you can try the following, if in windows:如果在 Windows 中,您可以尝试以下操作:

set HTTP_PROXY= <your proxy address without http://>

set HTTPS_PROXY=%HTTP_PROXY%

For eg:例如:

HTTP_PROXY=mycompany.myproxy.com:8080

HTTPS_PROXY=%HTTP_PROXY%

Worked for me为我工作

It can be temporary network issue as well.它也可能是暂时的网络问题。 Try restarting network services using command尝试使用命令重新启动网络服务

service network restart

If its *nix machine.如果它的 *nix 机器。

I had the same issue using ruby-2.0.0-p247 on OS X 10.8.5.我在 OS X 10.8.5 上使用ruby-2.0.0-p247时遇到了同样的问题。

Make sure the first line in Gemfile is using https://确保Gemfile的第一行使用https://

source 'https://rubygems.org'

I reinstalled that version of ruby.我重新安装了那个版本的 ruby​​。

rvm reinstall ruby-2.0.0

Ruby was upgraded ruby-2.0.0-p598 (version depends on latest patch). Ruby 升级为ruby-2.0.0-p598 (版本取决于最新补丁)。

bundle then worked without error although all the gems were reinstalled.尽管重新安装了所有宝石,但bundle仍然可以正常工作。

The other reason causing such that issues is the fact if you are behind proxy server.导致此类问题的另一个原因是您在代理服务器后面。 I describe here solution, maybe it will be usefull for someone else.我在这里描述解决方案,也许对其他人有用。 :) :)

In case that you did not know Login/pass for yours proxy, and meet this issues you could firstly check if you need to (re)install anything, by command:如果您不知道您的代理的登录/密码,并且遇到此问题,您可以首先通过命令检查是否需要(重新)安装任何东西:

C:\...> bundle check
Resolving dependencies...
The Gemfile's dependencies are satisfied

If you get other respons then above, you could find properly gems in properly versions here (rubygems.org) , then install it (from the directory with downloaded gem) by command:如果您在上面得到其他响应,您可以在此处 (rubygems.org)找到正确版本中的正确 gem,然后通过命令安装它(从下载 gem 的目录中):

gem install <gem-name> --locally 

I had this issue while working in Cloud 9. After trying several 'bundle install' and sending an email to c9 support(no reply) I was able to get it working by killing all the processes and doing a hard-restart of the IDE.我在 Cloud 9 中工作时遇到了这个问题。在尝试了几次“捆绑安装”并向 c9 支持发送电子邮件(没有回复)后,我能够通过终止所有进程并硬重启 IDE 来使其工作。

Do this by clicking directly on the little bar-graphs at the top of the right-hand side that show CPU, Memory, Disk.为此,请直接单击右侧顶部显示 CPU、内存、磁盘的小条形图。 Then click on the process list, select them all, and force kill.然后点击进程列表,全选,强行杀掉。 Then exit out of the process list.然后退出进程列表。 Click on the bar-graphs again, and this time click 'Restart'.再次单击条形图,这次单击“重新启动”。

After this I was able to run bundle with no problems.在此之后,我能够毫无问题地运行 bundle。

Either with http or https did not work.使用 http 或 https 都不起作用。

After I disabled the IP v6, it worked禁用 IP v6 后,它起作用了

https://support.purevpn.com/how-to-disable-ipv6-linuxubuntu https://support.purevpn.com/how-to-disable-ipv6-linuxubuntu

Use wget to see if you can reach the domain使用wget查看是否可以访问域

wget http://rubygems.org/latest_specs.4.8.gz

If this fails then try the following.如果失败,请尝试以下操作。

Edit your /etc/resolv.conf file and add these lines near the top to use Google's name servers编辑您的/etc/resolv.conf文件并在顶部附近添加这些行以使用 Google 的名称服务器

nameserver 8.8.8.8
nameserver 8.8.4.4

Adding variable for proxy worked fine.为代理添加变量工作正常。

Additionally if you are using Bitnami redmine like me you can add that into setenv.bat then when you start command line with Bitnami Redmine short cut it will be automatically added to your environment.此外,如果您像我一样使用 Bitnami redmine,您可以将其添加到 setenv.bat 中,然后当您使用 Bitnami Redmine 快捷方式启动命令行时,它将自动添加到您的环境中。 You can find this under Bitnami installation folder.您可以在 Bitnami 安装文件夹下找到它。

如果您使用的是 Cloud9,只需重新启动(命令 R)并重试

Sometimes it happens due to proxy you are using.有时它是由于您使用的代理而发生的。 I tried to resolve this by using a connection without proxy and all worked perfectly fine.我试图通过使用没有代理的连接来解决这个问题,并且一切正常。
Then try:然后尝试:

bundle update

And then go for然后去

bundle install

CHange your source form https to http after run运行后将源表单 https 更改为 http

sudo bundle update sudo bundle install sudo bundle update sudo bundle install

For me, restarting the computer worked.对我来说,重新启动计算机有效。 I had already reinstalled ruby, updated bundler, removed 's' https:// but none of them worked!我已经重新安装了 ruby​​,更新了 bundler,删除了 's' https:// 但它们都不起作用!

我的只是一个简单的网络问题,只需重启电脑/路由器

A very simple solution I've used recently to overcome Bundler::HTTPError Could not fetch specs from https://rubygems.org/ which doesn't require you to disable IPV6 globally in your system:我最近使用一个非常简单的解决方案来克服Bundler::HTTPError Could not fetch specs from https://rubygems.org/它不需要您在系统中全局禁用 IPV6:

  1. ping -4 rubygems.org - to get an IPV4 address ping -4 rubygems.org - 获取 IPV4 地址
  2. Add the following line to your /etc/hosts file (use whatever IP address from the previous command output cause it might change):将以下行添加到您的/etc/hosts文件中(使用上一条命令 output 中的任何 IP 地址,因为它可能会更改):
     151.101.129.227 rubygems.org

I just had to restart my wifi and it started working.我只需要重新启动我的wifi,它就开始工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM