安装 Rails 报错ERROR: While executing gem

在安装 Rails 报错

ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild Ruby (preferred) or use non-HTTPS sources

执行命令(可直接复制)

rvm reinstall 2.3.8 --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2q

再次执行命令

gem install rails -v 5.0.0

还是报错

ERROR:  SSL verification error at depth 0: certificate has expired (10)
ERROR:  Certificate /C=CN/ST=ZheJiang/L=HangZhou/O=Alibaba (China) Technology Co., Ltd./CN=*.taobao.org expired at 2018-12-05T03:16:02Z
ERROR:  SSL verification error at depth 0: certificate has expired (10)
ERROR:  Certificate /C=CN/ST=ZheJiang/L=HangZhou/O=Alibaba (China) Technology Co., Ltd./CN=*.taobao.org expired at 2018-12-05T03:16:02Z
ERROR:  SSL verification error at depth 0: certificate has expired (10)
ERROR:  Certificate /C=CN/ST=ZheJiang/L=HangZhou/O=Alibaba (China) Technology Co., Ltd./CN=*.taobao.org expired at 2018-12-05T03:16:02Z
ERROR:  Could not find a valid gem 'rails' (= 5.0.0), here is why:
          Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
          Unable to download data from https://ruby.taobao.org/ - SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://ruby.taobao.org/specs.4.8.gz)
ERROR:  SSL verification error at depth 0: certificate has expired (10)
ERROR:  Certificate /C=CN/ST=ZheJiang/L=HangZhou/O=Alibaba (China) Technology Co., Ltd./CN=*.taobao.org expired at 2018-12-05T03:16:02Z
ERROR:  SSL verification error at depth 0: certificate has expired (10)
ERROR:  Certificate /C=CN/ST=ZheJiang/L=HangZhou/O=Alibaba (China) Technology Co., Ltd./CN=*.taobao.org expired at 2018-12-05T03:16:02Z

提示镜像源https://ruby.taobao.org/ 不可用,接着执行命令

gem sources --remove https://ruby.taobao.org/

移除淘宝镜像源,接着添加以下镜像源,执行命令

gem sources --add https://gems.ruby-china.com/

你可能感兴趣的:(安装 Rails 报错ERROR: While executing gem)