Gem在Hyper-V中安装连接问题

时间:2012-09-12 14:59:14

标签: ruby-on-rails ruby rubygems virtual-machine hyper-v

我有一台通过Hyper-V运行的Windows Server 2010 VM。我可以从VM内部使用Web浏览器连接到各个宝石,但是当我为任何gem运行gem install时,连接超时,我在下面粘贴了错误。图像使用的是虚拟开关 - 您认为这会导致问题吗?我不确定如何解决这个问题。

C:\Ruby193\bin>gem install rails -V
Error fetching remote data:             Errno::ETIMEDOUT: A connection attempt f
ailed because the connected party did not properly respond after a period of tim
e, or established connection failed because connected host has failed to respond
. - connect(2) (http://rubygems.org/latest_specs.4.8.gz)
Falling back to local-only install
ERROR:  Could not find a valid gem 'rails' (>= 0) in any repository
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ETIMEDOUT: A connection attempt failed because the connected party di
d not properly respond after a period of time, or established connection failed
because connected host has failed to respond. - connect(2) (http://rubygems.org/
latest_specs.4.8.gz)

1 个答案:

答案 0 :(得分:3)

可能缺少的是代理配置(考虑到你可以浏览rubygems.org)

您可以在--http-proxy命令中使用gem install选项或设置HTTP_PROXY环境变量。

首先,您需要获取代理配置,这很可能是在您的网络浏览器中。

它应该是这样的:

http://host:port/

或者:

http://username:password@host:port/

您需要在gem install

中使用它
gem install rails --http-proxy=http://host:port/

或者,如果将其设置为环境变量,则可以避免每次键入它:

SET HTTP_PROXY=http://host:port/
gem install rails

您可以使用gem help install文档查看有关此内容的更多详细信息。

希望有所帮助。

相关问题