如何解决捆绑安装 rake 错误和 Gem::RemoteFetcher::FetchError

How to resolve bundle install rake error and Gem::RemoteFetcher::FetchError

当我 运行 bundle install 在 ruby 2.1.2 我得到:

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/rake-10.4.2.gem)
An error occurred while installing rake (10.4.2), and Bundler cannot continue.
Make sure that `gem install rake -v '10.4.2'` succeeds before bundling.

当我 运行 gem install rake 我得到:

ERROR:  Could not find a valid gem 'bundle' (>= 0), here is why:
      Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

当我 运行 which bundle 我得到:

/usr/local/rvm/gems/ruby-2.1.2@global/bin/bundle

此错误使我无法在部署前对 localhost:3000 进行开发工作。

有谁知道如何解决这个问题?

在您的 rails 应用程序目录中的 Gemfile 中更改:

source 'https://rubygems.org'

source 'http://rubygems.org'

升级到 Ruby 的最新版本或至少比您现有的版本更新的版本。我正在使用 2.0.0-p247 并收到相同的错误。当我升级到 2.2.5(这是撰写本文时受支持的最旧版本)时,一切正常。

升级 ruby 后,我还必须 运行 gem install bundler。最后,我使用 rbenv 并安装 ruby 和 rbenv install 2.2.5 然后 运行 rbenv local 2.2.5.