Ruby 和“您必须使用 OpenSSL 支持重新编译 Ruby 或更改 Gemfile 中的源”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15212104/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 05:48:17  来源:igfitidea点击:

Ruby and "You must recompile Ruby with OpenSSL support or change the sources in your Gemfile"

rubymacosopensslrvm

提问by covard

Using rvm I upgraded my ruby to 1.9.3-p392, also added 2.0.0, anytime I try to use this version when I run my bundle command I get this error.

使用 rvm 我将我的 ruby​​ 升级到 1.9.3-p392,还添加了 2.0.0,每当我在运行 bundle 命令时尝试使用此版本时,我都会收到此错误。

Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using RVM are
available at rvm.io/packages/openssl.

I have followed several different instructions on how to fix this. I have tried removing the version and installing it with the rvm options

我已经按照几个不同的说明来解决这个问题。我尝试删除版本并使用 rvm 选项安装它

--with-openssl-dir=$HOME/.rvm/usr

I have installed OpenSSL with rvm, and macports. Both have not helped the problem. I even changed the file location of the ssl cert using this:

我已经安装了带有 rvm 和 macports 的 OpenSSL。两者都没有帮助解决问题。我什至使用以下方法更改了 ssl 证书的文件位置:

export SSL_CERT_FILE=/Users/DarkLord/.rvm/usr/ssl/cert.pem

No matter what I do I continue to get the error. Can someone please help me fix this?

无论我做什么,我都会继续收到错误消息。有人可以帮我解决这个问题吗?

采纳答案by thekingoftruth

The new way to do it, according to a comment by @PurpleHymanet above, is the following:

根据上面@PurpleHymanet 的评论,新的方法如下:

rvm autolibs homebrew
rvm install 2.1.1
rvm use 2.1.1

It's much easier.

这要容易得多。

回答by Anh Nguyen

This works for me:

这对我有用:

rvm get stable

rvm get stable

brew install libyaml

brew install libyaml

rvm pkg install openssl

rvm pkg install openssl

rvm install ruby-2.0.0 --with-openssl-dir=$HOME/.rvm/usr

rvm install ruby-2.0.0 --with-openssl-dir=$HOME/.rvm/usr

rvm use ruby-2.0.0

rvm use ruby-2.0.0

All credits go to https://coderwall.com/p/tptocq

所有学分转到https://coderwall.com/p/tptocq

回答by virtax

This helps me install 1.9.3-head on Mac:

这有助于我在 Mac 上安装 1.9.3-head:

rvm get latest    
brew install openssl    
rvm reinstall 1.9.3-head --with-openssl-dir=`brew --prefix openssl`

回答by dktistakis

In my case after:

在我的情况下:

 1. brew install openssl
 2. rvm install ruby-2.6.0

bundle installfailed with this error. The problem was that openssl was globally set so I had to install the new ruby version by setting the openssl directory explicitly.

bundle install因此错误而失败。问题是 openssl 是全局设置的,所以我必须通过显式设置 openssl 目录来安装新的 ruby​​ 版本。

So what I had to do was:

所以我必须做的是:

 1. rvm reinstall ruby-2.6.0 --with-openssl-dir=/usr/local/opt/openssl
 2. rvm reload

Assuming that usr/local/opt/opensslis where it is installed.

假设这usr/local/opt/openssl是它的安装位置。

After that bundle installran successfully.

之后bundle install运行成功。

Warningwhen I tried this command with this path /usr/locallike some answers suggested, it didn't work.

警告当我/usr/local像某些答案建议的那样使用此路径尝试此命令时,它不起作用。

回答by covard

To get this working again I had to install homebrew and move my mac ports out of the way. Then do the following after removing 1.9.3-p392 and 2.0.0-p0:

为了让它再次工作,我必须安装自制软件并将我的 mac 端口移开。然后在删除 1.9.3-p392 和 2.0.0-p0 后执行以下操作:

rvm get head --autolibs=3
rvm install 1.9.3 --with-opt-dir=/usr/bin
rvm install 2.0.0

There was something not working with my mac ports and openssl and make and configure. This was the only way I was able to get rvm to install ruby again with out getting openssl issues or make/configure issues.

有一些东西不适用于我的 mac 端口和 openssl 以及 make 和 configure。这是我能够让 rvm 再次安装 ruby​​ 而不会出现 openssl 问题或 make/configure 问题的唯一方法。

回答by Solomon

In my case:

就我而言:

Problem:After installing ruby-2.3.1, I ran the command bundle installand then the error occurred.

问题:安装ruby-2.3.1后,我运行命令bundle install,然后出现错误。

Solution:

解决方案:

  • I first installed OpenSSLon my machine. $ brew install openssl
  • And then, reinstalled the ruby version I require (2.3.1) with the openssl.

    $ rvm reinstall 2.3.1 --with-openssl-dir=/usr/local/opt/openssl

  • 我首先在我的机器上安装了OpenSSL$ brew install openssl
  • 然后,使用 openssl 重新安装我需要的 ruby​​ 版本(2.3.1)。

    $ rvm reinstall 2.3.1 --with-openssl-dir=/usr/local/opt/openssl

And this solved my problem!

这解决了我的问题!

回答by LiAh Sheep

According to the following question: How to tell which openssl lib is actually being used by an RVM-installed ruby

根据以下问题: 如何判断 RVM 安装的 ruby​​ 实际使用的是哪个 openssl 库

It seems that the options --with-openssl-dir=...is no longer valid as of Ruby 1.9.3. I tried

--with-openssl-dir=...Ruby 1.9.3 开始,这些选项似乎不再有效。我试过

rvm install 1.9.3 --with-opt-dir=/usr/local --with-openssl

and it worked.

它奏效了。

回答by Dinobi

The following steps worked for me.

以下步骤对我有用。

First ensure opensslis installed by running brew install openssl, then reinstall the ruby version using rvm, but this time around, you have to pass the with-opt-dirflag pointing to the location where openssl was installed on your machine (use command which opensslto find this location).

首先确保openssl通过运行安装brew install openssl,然后使用 rvm 重新安装 ruby​​ 版本,但这一次,您必须传递with-opt-dir指向您机器上安装 openssl 位置的标志(使用命令which openssl查找此位置)。

rvm install 1.9.3-p392 --with-openssl-dir=/usr/local/opt/openssl

回答by PGill

macOS Catalina

macOS Catalina

brew install rbenv/tap/[email protected]
rvm reinstall 2.3.8 --with-openssl-dir=/usr/local/opt/[email protected]

回答by smithWEBtek

I specified a more recent Ruby version in my Gemfile, then ran bundle install. All good now.

我在 Gemfile 中指定了更新的 Ruby 版本,然后运行 ​​bundle install。现在一切都很好。