ruby 如何告诉 gem 命令不要使用 SSL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20399531/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to tell gem command not to use SSL
提问by Omid Kamangar
I am trying to run the gemcommand to install/update some gems, but due to some network restrictions in this area, I get this error:
我正在尝试运行gem命令来安装/更新一些 gem,但由于该区域的一些网络限制,我收到此错误:
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 gemnot to use SSL, to avoid the error?
(我认为)这主要是因为篡改了 SSL 证书。
无论如何要告诉gem不要使用SSL,以避免错误?
回答by Leo Gallucci
Use HTTP instead of HTTPS if you are unable to solve the certs issue:
如果您无法解决证书问题,请使用 HTTP 而不是 HTTPS:
$ gem install rails --source http://rubygems.org
To avoid repeating this every time, either edit your ~/.gemrcor edit the file through the command line, like this:
为避免每次都重复此操作,请~/.gemrc通过命令行编辑或编辑文件,如下所示:
$ gem sources --add http://rubygems.org
$ gem sources --remove https://rubygems.org
$ gem sources --list
*** CURRENT SOURCES ***
http://rubygems.org
Also, en every Gemfileyou will need to change the first line from:
此外,Gemfile您需要将第一行更改为:
source 'https://rubygems.org'
To:
到:
source 'http://rubygems.org'
Of course it would be much better if you manage to solve the certsissue as @p11y suggested on his comment.
当然,如果您certs像@p11y 在他的评论中建议的那样设法解决问题,那会好得多。
回答by JerodG
The accepted answer didn't work for me. The following, however, did.
接受的答案对我不起作用。然而,以下做到了。
Edit .gemrc file - On Windows c:\Users\yourusername\.gemrc
编辑 .gemrc 文件 - 在 Windows c:\Users\yourusername\.gemrc
add:
添加:
:ssl_verify_mode: 0
It displayed the SSL errors but the install was successful.
它显示 SSL 错误,但安装成功。

