【问题标题】:SSL Error When Making New Rails Project新建 Rails 项目时出现 SSL 错误
【发布时间】:2013-04-13 18:49:57
【问题描述】:

当我使用 rails new projectname -d mysql 创建一个新的 rails 项目(在 Windows 上)时,它会创建所有文件,然后在尝试执行 bundle install 时返回此文件:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/vendor/net/http/pe
rsistent/ssl_reuse.rb:70:in `connect': SSL_connect returned=1 errno=0 state=SSLv
3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/vendo
r/net/http/persistent/ssl_reuse.rb:70:in `block in connect'
        from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
        from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/vendo
r/net/http/persistent/ssl_reuse.rb:70:in `connect'
        from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
        from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:750:in `start'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/vendo
r/net/http/persistent.rb:628:in `start'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/vendo
r/net/http/persistent.rb:570:in `connection_for'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/vendo
r/net/http/persistent.rb:930:in `request'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/fetch
er.rb:195:in `fetch'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/fetch
er.rb:169:in `use_api'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/sourc
e/rubygems.rb:223:in `block in remote_specs'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/sourc
e/rubygems.rb:223:in `select'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/sourc
e/rubygems.rb:223:in `remote_specs'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/sourc
e/rubygems.rb:162:in `fetch_specs'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/sourc
e/rubygems.rb:66:in `specs'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/defin
ition.rb:192:in `block (2 levels) in index'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/defin
ition.rb:189:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/defin
ition.rb:189:in `block in index'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/index
.rb:9:in `build'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/defin
ition.rb:185:in `index'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/defin
ition.rb:179:in `resolve'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/defin
ition.rb:114:in `specs'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/defin
ition.rb:109:in `resolve_remotely!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/insta
ller.rb:83:in `run'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/insta
ller.rb:14:in `install'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/cli.r
b:247:in `install'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/vendo
r/thor/task.rb:27:in `run'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/vendo
r/thor/invocation.rb:120:in `invoke_task'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/vendo
r/thor.rb:344:in `dispatch'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/vendo
r/thor/base.rb:434:in `start'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/bin/bundle:20:in
`block in <main>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/frien
dly_errors.rb:4:in `with_friendly_errors'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/bin/bundle:20:in
`<main>'
        Unfortunately, a fatal error has occurred. Please see the Bundler
        troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!

我在使用 Ruby 2.0 时遇到了同样的错误,并认为这可能是问题所在,但在 Ruby 1.9.3(我用于此的版本)中也发生了同样的事情。

【问题讨论】:

标签: ruby-on-rails ruby ssl


【解决方案1】:

经过一番谷歌搜索后,我发现了一个指南,该指南向您展示了如何添加正确的 SSL 证书文件(原来是问题所在):

https://gist.github.com/fnichol/867550

【讨论】:

    【解决方案2】:

    我遇到了问题。我更改了gem源,然后问题已经解决了。 首先,使用以下命令检查 gem 源:

    gem sources -l

    应该是“https://rubygems.org/”。

    其次,使用以下命令删除gem源:

    gem sources --remove https://rubygems.org/

    第三,使用以下命令添加一个新的gem源:

    gem sources -a http://rubygems.org/

    如果您在中国,您也可以使用淘宝宝石资源:

    gem sources -a http://ruby.taobao.org/

    终于好了。


    当你创建一个新项目时,如果你遇到了这个问题。您可以在 Gemfile 文件中更改 gem 源。

    更改宝石来源

    来自

    source 'https://rubygems.org/'

    source 'http://rubygems.org/'

    如果您在中国,您也可以使用淘宝宝石资源:

    source 'http://ruby.taobao.org/'

    那么你应该运行以下命令:

    bundle install

    祝你好运!


    我英语不好。所以,对不起。

    【讨论】:

      【解决方案3】:

      如果在 linux 上,请尝试安装 libssl-dev,然后从源代码重新编译 openssl

      sudo apt-get install libssl-dev

      如果您从源代码编译 ruby​​,请导航到您的 ruby​​ 源代码并进入 ext/openssl 目录。

      在那里,做./configure &amp;&amp; make &amp;&amp; make install

      看看您是否能够创建新的 rails 应用程序。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-02-12
        • 1970-01-01
        • 1970-01-01
        • 2014-06-07
        • 2020-02-09
        • 2019-04-20
        • 2017-07-29
        • 2015-12-09
        相关资源
        最近更新 更多