[英]SSL certificate verify failed when installing gems
I set up Rails project and database on Windows and some gems are missing. 我在Windows上设置了Rails项目和数据库,缺少了一些功能。 When trying to install them I get the following error: 尝试安装它们时,出现以下错误:
Following gems were not installed: bundler: Could not find a valid gem 'bundler' (>= 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 (https://api.rubygems.org/specs.4.8.gz)
I tried 我试过了
https://gist.github.com/luislavena/f064211759ee0f806c88 https://gist.github.com/luislavena/f064211759ee0f806c88
and 和
SSL Error When installing rubygems, Unable to pull data from 'https://rubygems.org/ SSL错误安装rubygems时,无法从'https://rubygems.org/提取数据
but non of this worked. 但没有一个可行。 Any ideas? 有任何想法吗?
As a temporary workaround, you can simply change source 'https://rubygems.org'
in your gemfile to source http://rubygems.org
. 作为临时的解决方法,您只需将gemfile中的source 'https://rubygems.org'
更改为source http://rubygems.org
。 Then run bundle
. 然后运行bundle
。
I've had the exact same problem before, and after that, I was able to install my gems. 在此之前,我遇到了完全相同的问题,之后,我能够安装我的宝石。
For a better solution, run gem update --system
为了获得更好的解决方案,请运行gem update --system
For Windows with PowerShell installed 对于安装了PowerShell的Windows
Installing Windows PowerShell 安装Windows PowerShell
Paste this 1line code in command console: (WIN + R, cmd) 将此1行代码粘贴到命令控制台中:(WIN + R,cmd)
powershell -Command "& {$fname='cacert.pem'; $outpath=\"$($(Get-ChildItem Env:USERPROFILE).Value)/$fname\"; Invoke-WebRequest http://curl.haxx.se/ca/$fname -OutFile \"$outpath\"; [Environment]::SetEnvironmentVariable('SSL_CERT_FILE', \"$outpath\", 'User')}"
Script will do: 脚本将执行以下操作:
Download http://curl.haxx.se/ca/cacert.pem 下载http://curl.haxx.se/ca/cacert.pem
Save it as %USERPROFILE%/cacert.pem ( C:\\Users\\__you__\\cacert.pem)
将其另存为%USERPROFILE%/cacert.pem ( C:\\Users\\__you__\\cacert.pem)
Set persistent environment variable for current user SSL_CERT_FILE
as %USERPROFILE%/cacert.pem
将当前用户SSL_CERT_FILE
持久性环境变量设置为%USERPROFILE%/cacert.pem
After this try to install the gem 在此之后,尝试安装gem
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.