当前位置: 首页 > 知识库问答 >
问题:

安装gems时SSL证书验证失败

高宏峻
2023-03-14

我在Windows上设置了Rails项目和数据库,一些宝石丢失了。当试图安装他们我得到以下错误:

    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)

我试过了

https://gist.github.com/luislavena/f064211759ee0f806c88

SSL错误安装rubygem时,无法从https://rubygems.org/

但这些都没有奏效。有什么想法吗?

共有2个答案

马丰
2023-03-14

适用于安装了PowerShell的Windows

安装Windows PowerShell

在命令控制台中粘贴此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')}"

脚本将做:

>

将其另存为%USERPROFILE%/cacert。pem(C:\Users\\uuuu you\uuuu\cacert.pem)

为当前用户设置持久化环境变量SSL_CERT_FILE%USERPROFILE%/cacert.pem

在此之后,请尝试安装gem

苏昊英
2023-03-14

作为一个临时的解决方案,您可以简单地将gefile中的Source'https://rubygems.org'更改为Sourcehttp://rubygems.org。然后运行bundle

我以前也遇到过同样的问题,之后,我就可以安装我的gems了。

要获得更好的解决方案,请运行gem更新系统

 类似资料: