安装ruby on rails错误:Unable to download data from https://rubygems.org/的解决方法

本文为大家讲解的是在用gem install rails安装ruby on rails时一直报这个错误的解决方法,感兴趣的同学参考下。

完整的错误信息如下:

ERROR:  Could not find a valid gem 'rails' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT: Connection timed out - connect(2) for "s3.amazonaws.com" port 443 (https://api.rubygems.org/latest_specs.4.8.gz)

解决方案:

sudo gem sources -r https://rubygems.org
sudo gem sources -a http://rubygems.org  

貌似意思是将https替换成http,再试了一下,果然可以了,但是安装完后别忘了把它设回来:

sudo gem sources -r http://rubygems.org
sudo gem sources -a https://rubygems.org

你可能感兴趣的:(安装ruby on rails错误:Unable to download data from https://rubygems.org/的解决方法)