49

使用 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.

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

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

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

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

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

4

13 回答 13

79

这对我有用:

rvm get stable

brew install libyaml

rvm pkg install openssl

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

rvm use ruby-2.0.0

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

于 2013-05-06T10:21:18.867 回答
47

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

rvm get latest    
brew install openssl    
rvm reinstall 1.9.3-head --with-openssl-dir=`brew --prefix openssl`
于 2017-06-15T15:24:26.010 回答
12

在我的情况下:

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

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

所以我必须做的是:

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

假设usr/local/opt/openssl这是安装它的地方。

之后bundle install就成功运行了。

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

于 2019-04-11T15:48:09.020 回答
9

为了让它再次工作,我必须安装自制软件并将我的 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

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

于 2013-03-06T20:08:22.400 回答
6

就我而言:

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

解决方案:

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

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

这解决了我的问题!

于 2019-12-18T17:46:38.293 回答
5

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

rvm autolibs homebrew
rvm install 2.1.1
rvm use 2.1.1

这要容易得多。

于 2019-12-21T00:24:11.787 回答
4

根据以下问题: 如何判断 RVM-installed ruby​​ 实际使用了哪个 openssl lib

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

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

它奏效了。

于 2013-03-05T04:23:37.133 回答
3

macOS 卡塔利娜

brew install rbenv/tap/openssl@1.0
rvm reinstall 2.3.8 --with-openssl-dir=/usr/local/opt/openssl@1.0
于 2020-04-06T04:36:46.837 回答
2

以下步骤对我有用。

首先确保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
于 2019-07-19T18:40:11.873 回答
1

在 macOS 10.14、Ruby 2.5.3 和 OpenSSL 1.0.2n 这对我有用:

./configure --with-openssl --with-openssl-dir=/usr/local/ssl

但我只是在尝试错误消息告诉我的内容:

*** Following extensions are not compiled:
openssl:
    Could not be configured. It will not be installed.
    /Users/brian/Desktop/Ruby/ruby-2.5.3/ext/openssl/extconf.rb:97: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
    Check ext/openssl/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.
make[1]: *** [note] Error 1
于 2018-11-02T01:37:02.880 回答
0

这对我有帮助:

rvm reinstall 2.5

brew tap raggi/ale
brew install openssl-osx-ca
brew services start openssl-osx-ca

在这里找到了这个解决方案:https ://github.com/raggi/openssl-osx-ca#readme

于 2019-01-11T12:13:45.330 回答
0

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

于 2020-02-16T15:16:44.307 回答
0

我在处理Ruby 2.2.3应用程序时遇到了这个问题。

我以前卸载了我机器上的MySQL 数据库服务器,因为我不需要它。但是,我仍然需要mysql2 gem,因为我的应用程序正在连接到另一个应用程序的 MySQL 数据库以提取数据。

但是,当我尝试运行bundle命令时出现错误:

无法加载 OpenSSL。您必须使用 OpenSSL 支持重新编译 Ruby,或将 Gemfile 中的源代码从“https”更改为“http”。rvm.io/packages/openssl 提供了使用 RVM 使用 OpenSSL 进行编译的说明。

这是我解决它的方法

这个问题是由于我在我的机器上libssl-dev卸载MySQL 数据库服务器及其库时删除了库引起的。

首先,我运行以下命令重新安装ruby,因为我使用以下命令安装它rvm

rvm reinstall ruby-2.2.3

这引发了一个错误:

使 gemset ruby​​-2.2.3 原始...................................... .../- .'command gem pristine --extensions mysql2 --version 0.5.3' 失败,您需要手动修复这些 gem。. 运行“__rvm_with ruby​​-2.2.3 gemset_pristine”时出错,请阅读/home/promisepreston/.rvm/log/1630094455_ruby-2.2.3/gemset.pristine-ruby-2.2.3.log

接下来,我尝试安装 mysql2 gem:

gem install mysql2

然后我遇到了这个错误:

构建原生扩展。这可能需要一段时间... 错误:安装 mysql2 时出错:错误:无法构建 gem 原生扩展。mysql 客户端丢失。您可能需要“sudo apt-get install libmariadb-dev”、“sudo apt-get install libmysqlclient-dev”或“sudo yum install mysql-devel”,然后重试。

最后,我使用以下命令安装了 mysql 客户端库:

sudo apt-get install libmysqlclient-dev

注意:这也会同时安装libssl-dev库。

一切正常。

就这样。

于 2021-08-27T20:40:30.207 回答