How to tell gem command not to use SSL
Asked Answered
G

3

39

I am trying to run the gem command to install/update some gems, but due to some network restrictions in this area, I get this error:

ERROR:  While executing gem ... (OpenSSL::SSL::SSLError)
    SSL_connect returned=6 errno=0 state=SSLv3 read finished A

(I think) this is mainly because of tampering with the SSL certificates.
Is there anyway to tell gem not to use SSL, to avoid the error?

Gnaw answered 5/12, 2013 at 12:3 Comment(1)
possible duplicate of Dreaded OpenSSL::SSL::SSLError on Rubygems when using HTTPS sourceKimberleekimberley
P
70

Use HTTP instead of HTTPS if you are unable to solve the certs issue:

$ gem install rails --source http://rubygems.org

To avoid repeating this every time, either edit your ~/.gemrc or edit the file through the command line, like this:

$ gem sources --add http://rubygems.org
$ gem sources --remove https://rubygems.org
$ gem sources --list

*** CURRENT SOURCES ***
http://rubygems.org

Also, en every Gemfile you will need to change the first line from:

source 'https://rubygems.org'

To:

source 'http://rubygems.org'

Of course it would be much better if you manage to solve the certs issue as @p11y suggested on his comment.

Phenyl answered 5/12, 2013 at 13:3 Comment(2)
Note: If you get the error source https://rubygems.org not present in cache you need to add a forward-slash to the end of the url so you use: $ gem sources --remove https://rubygems.org/Dianthe
Might also run into this error: https://mcmap.net/q/409183/-can-39-t-add-sources-with-gemMacmacabre
C
29

The accepted answer didn't work for me. The following, however, did.

Edit .gemrc file

  • On Windows c:\Users\yourusername\.gemrc

Specifically %HOMEPATH% in the event your path is different.

add:

:ssl_verify_mode: 0

It displayed the SSL errors but the install was successful.

Coalesce answered 4/3, 2019 at 17:32 Comment(1)
This worked for me when the accepted answer didn't, thanks :) In case this doesn't work for anybody, it's worth knowing that .gemrc needs to go in specifically %HOMEDRIVE%%HOMEPATH%, which might not always be your C:\Users\username folder. (It wasn't in my case, which had me stumped for a while!)Ataractic
C
0

You can also download the gem from rubygems.org with your browser, then install it locally. Simpler and more secure than downloading via HTTP too.

$ gem install path/filename.gem
Charlton answered 21/5 at 10:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.