ruby “在任何存储库中都找不到有效的 gem”(rubygame 和其他)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9962051/
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
"Could not find a valid gem in any repository" (rubygame and others)
提问by Reiswindy
I've been trying to install this 'rubygame' gem for some time, but whenever I use the command
我一直在尝试安装这个“rubygame” gem 一段时间,但是每当我使用命令时
gem install rubygame
it will give an error:
它会给出一个错误:
ERROR: Could not find a valid gem 'rubygame' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ETIMEDOUT: Connection timed out - connect(2) (http://rubygems.org/latest_specs.4.8.gz)
I've also tried other gems but with similar results:
我也尝试过其他宝石,但结果相似:
ERROR: Could not find a valid gem 'rake' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ETIMEDOUT: Connection timed out - connect(2) (http://rubygems.org/latest_specs.4.8.gz)
I've already made sure I have an internet connection, and have already tried reinstalling both ruby and rubygems (currently using ruby 1.8, rubygems 1.7.2). Googling didn't help me at all. I would be very grateful if anyone can solve my problem. My sources list only shows http://rubygems.org
我已经确定我有互联网连接,并且已经尝试重新安装 ruby 和 rubygems(目前使用 ruby 1.8,rubygems 1.7.2)。谷歌搜索根本没有帮助我。如果有人能解决我的问题,我将不胜感激。我的来源列表只显示http://rubygems.org
回答by Joshua Cheek
Check if you have "https://rubygems.org/" as a source to find gems at:
检查您是否有“ https://rubygems.org/”作为在以下位置找到宝石的来源:
$ gem sources
*** CURRENT SOURCES ***
https://rubygems.org/
If not, you should be able to add it with
如果没有,您应该可以添加它
$ gem sources --add https://rubygems.org/
https://rubygems.org/ added to sources
Hereare docs for the gem sourcecommand.
这是gem source命令的文档。
回答by Apprentice
You can also add the source you want on the command whenever you have troubles using https, like this:
您还可以在使用 https 时遇到问题时在命令中添加所需的源,如下所示:
gem install GEMNAME --source http://rubygems.org
It's better to fix the SSL problem though.
不过最好解决 SSL 问题。
回答by aakash
are you behind any proxy?
您是否支持任何代理?
check your browser for proxy that you might use:
检查您的浏览器是否有您可能使用的代理:
execute the command: gem install xxx --http-proxy=http://user:password@serverand you should be good to go.
执行命令:gem install xxx --http-proxy=http://user:password@server你应该很高兴。
回答by joelparkerhenderson
You don't have an Internet connection to rubygems.org.
您没有到 rubygems.org 的 Internet 连接。
This happens sometimes if the site is down or blocked.
如果站点关闭或被阻止,有时会发生这种情况。
This command can show you if your connection has a way to reach rubygems.org:
此命令可以显示您的连接是否可以访问 rubygems.org:
traceroute rubygems.org
回答by Peter Host
Maybe you should try
也许你应该试试
gem list -r
then
然后
gem install -r rubygame
Also note that with rvmon MacosX (Lion in my case) you should install ruby-1.9.3-p194(for Xcode 4.x compiler considerations) then
另请注意,rvm在 MacosX(在我的情况下为 Lion)上,您应该安装ruby-1.9.3-p194(出于 Xcode 4.x 编译器的考虑)然后
rvm rubygems current
and in my case I had to use
就我而言,我不得不使用
rvm use ruby-1.9.3-p194@global
(which contains bundler, rake, rubygems-bundlerand rvm)
(其中包含bundler、rake、rubygems-bundler和rvm)
and not
并不是
rvm use ruby-1.9.3-p194
(which is empty)
(这是空的)
回答by joelparkerhenderson
Can you post your versions?
你能发布你的版本吗?
ruby -v
#=> ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
gem -v
#=> 1.8.19
If your gem command is not current, you can update it like this:
如果您的 gem 命令不是最新的,您可以像这样更新它:
gem update --system
To see if you can connect to rubygems.org using Ruby:
要查看您是否可以使用 Ruby 连接到 rubygems.org:
require 'net/http'
require 'uri'
puts Net::HTTP.get URI.parse('https://rubygems.org')
If yes, that's good.
如果是,那很好。
If no, then somehow Ruby is blocked from opening a net connection. Try these and see if any of them work:
如果没有,那么不知何故 Ruby 被阻止打开网络连接。试试这些,看看它们中的任何一个是否有效:
curl https://rubygems.org
curl https://rubygems.org --local-port 1080
curl https://rubygems.org --local-port 8080
env | grep -i proxy
If you're using a company machine, or within a company firewall, or running your own firewall, you may need to use a proxy.
如果您使用的是公司机器,或在公司防火墙内,或运行您自己的防火墙,则可能需要使用代理。
For info on Ruby and proxies see http://www.linux-support.com/cms/http-proxies-and-ruby/
有关 Ruby 和代理的信息,请参阅 http://www.linux-support.com/cms/http-proxies-and-ruby/
回答by gotqn
I have fixed this issue using the proxy command option of gem install. It has the following format:
我已经使用 gem install 的代理命令选项修复了这个问题。它具有以下格式:
$ gem install --http-proxy http://201.187.107.19:8080 rubygame
Note, the IP address and the port number refers to a proxy. You should search for a proxy list and use one of the proxies there.
请注意,IP 地址和端口号是指代理。您应该搜索代理列表并使用其中的代理之一。
This is site with proxies: http://www.cybersyndrome.net/pla5.html
这是带有代理的站点:http: //www.cybersyndrome.net/pla5.html
Also, I have to try 7 or 8 different proxies in order to succeed. Do not give up.
此外,我必须尝试 7 或 8 个不同的代理才能成功。不放弃。
回答by Wasim Khan
Use :
用 :
gem sources --add http://rubygems.org/
gem 来源 --add http://rubygems.org/
Do you want to add this insecure source? [yn] [YES]
您要添加这个不安全的来源吗?[yn] [是]
then use
然后使用
gem install sass
宝石安装sass
and done
并做了
回答by Snake Sanders
I have tried most of the solutions suggested here but I had no luck. I found a solution that worked for me, which was manually updating the gemfile to 2.6.7. The guide on how to do is in guides.rubygems.org: installing-using-update-packages
我已经尝试了这里建议的大多数解决方案,但我没有运气。我找到了一个对我有用的解决方案,它手动将 gemfile 更新到 2.6.7。关于如何做的指南是guides.rubygems.org:安装,使用,更新包
Download rubygems-update-2.6.7.gemto your C:\
Now, using your Command Prompt:
将rubygems-update-2.6.7.gem下载到您的 C:\
现在,使用您的命令提示符:
C:\>gem install --local C:\rubygems-update-2.6.7.gem
C:\>update_rubygems --no-ri --no-rdoc
After this, gem --version should report the new update version (2.6.7).
You can now safely uninstall rubygems-update gem:
在此之后, gem --version 应该报告新的更新版本(2.6.7)。
您现在可以安全地卸载 rubygems-update gem:
C:\>gem uninstall rubygems-update -x
Removing update_rubygems
Successfully uninstalled rubygems-update-2.6.7
The reason why this did not work before was because server used certificates SHA-1, now this was updated to SHA-2.
之前这不起作用的原因是因为服务器使用了证书 SHA-1,现在已更新为 SHA-2。
回答by Farhan Ahmad
I know this is a little late, but I was also having this issue a while ago. This is what worked for me:
我知道这有点晚了,但不久前我也遇到了这个问题。这对我有用:
REALLY_GEM_UPDATE_SYSTEM=1
sudo gem update --system
sudo gem install rails
Hope this helps anyone else having this issue :)
希望这可以帮助其他遇到此问题的人:)

