解决GEM不能用的问题

最近在安装jekyll的时候,用到gem命令,但是运行出行如下错误

1
2
3
4
5
6
gem install jekyll
ERROR:  Could not find a valid gem 'jekyll' (>= 0), here is why:
        Unable to download data from https://rubygems.org/
         - Errno::ECONNREFUSED: Connection refused
         - connect(2) for "rubygems.global.ssl.fastly.net" port 443 
         (https://api.rubygems.org/latest_specs.4.8.gz)

原因是ruby 的gem被和谐了,现在淘宝的ruby工程师架设了rubygems的国内镜像。使用方法如下:

1
2
3
4
5
6
$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org

然后在运行gem命令就可以了!

1
gem install jekyll