[Ruby新手教学] 要有中国特色

今天部署一个系统,发现不能获取gem包,于是看看怎么回事

$ gem -v
1.3.6
$ gem update --system
JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
Updating RubyGems
Updating rubygems-update
ERROR:  While executing gem ... (Gem::GemNotFoundException)
    could not find gem rubygems-update locally or in a repository
$ gem install rubygems-update
JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
ERROR:  could not find gem rubygems-update locally or in a repository

 不知道为什么连不上,试试看,好像可以ping通

$ gem source
*** CURRENT SOURCES ***

http://rubygems.org/

$ ping rubygems.org
PING rubygems.org (72.4.120.124) 56(84) bytes of data.
64 bytes from rubygems.org (72.4.120.124): icmp_seq=2 ttl=49 time=368 ms

于是决定下载,这时发现了问题

$ wget http://rubygems.org/downloads/rubygems-update-1.8.5.gem
--2011-07-13 15:43:40--  http://rubygems.org/downloads/rubygems-update-1.8.5.gem
正在解析主机 rubygems.org... 72.4.120.124
Connecting to rubygems.org|72.4.120.124|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:http://rubygems.org/gems/rubygems-update-1.8.5.gem [跟随至新的 URL]
--2011-07-13 15:43:42--  http://rubygems.org/gems/rubygems-update-1.8.5.gem
Reusing existing connection to rubygems.org:80.
已发出 HTTP 请求,正在等待回应... 302 Found
位置:http://production.cf.rubygems.org/gems/rubygems-update-1.8.5.gem [跟随至新的 URL]
--2011-07-13 15:43:42--  http://production.cf.rubygems.org/gems/rubygems-update-1.8.5.gem
正在解析主机 production.cf.rubygems.org... 失败:域名解析暂时失败。
wget: unable to resolve host address `production.cf.rubygems.org'
 

进一步了解,发现是DNS污染,现在问题就简单了,查到对应的ip,然后修改

sudo vi /etc/hosts

216.137.53.162 production.cf.rubygems.org

下面就好办了

总结,在贵国,要考虑的问题有很多

相关推荐