Amja
Amja

Reputation: 1387

SSL Error When Making New Rails Project

When I make a new rails project (on Windows) with rails new projectname -d mysql, it creates all the files and then returns this when it tries to perform 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!

I got the same error with Ruby 2.0 and thought that might be the problem but the same thing happened with Ruby 1.9.3 (the version I used for this).

Upvotes: 2

Views: 1422

Answers (3)

diguage
diguage

Reputation: 397

I had the problem.I changed the gem source, then the problem has been solved. First, check the gem sources with the following command:

gem sources -l

It should be 'https://rubygems.org/'.

Second, remove the gem sources with the following command:

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

Third, add a new gem sources with the following command:

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

If you are in China, you also use the Taobao gem sources:

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

Finally, it is OK.


When you created a new project,If you met this problem. You can change gem sources in th Gemfile file.

Change the gem sources

from

source 'https://rubygems.org/'

to

source 'http://rubygems.org/'

If you are in China, you also use the Taobao gem sources:

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

then you should run the following command:

bundle install

Good Luck!


I'm not good at English.So, I am sorry.

Upvotes: 1

Amja
Amja

Reputation: 1387

After a bit of Googling, I came across a guide which shows you how to add the right SSL Cert file (which turned out to be the problem):

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

Upvotes: 1

kobaltz
kobaltz

Reputation: 7070

If on linux, try installing libssl-dev and then recompile openssl from source.

sudo apt-get install libssl-dev

If you compiled ruby from source, navigate to your ruby source and go into the ext/openssl directory.

Within there, do ./configure && make && make install

See if you're able to create your new rails app.

enter image description here

Upvotes: 0

Related Questions