安装 ruby​​-2.1.2:无法加载此类文件 -- openssl (LoadError) [英] Installing ruby-2.1.2: Cannot load such file -- openssl (LoadError)

查看:22
本文介绍了安装 ruby​​-2.1.2:无法加载此类文件 -- openssl (LoadError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 rvm 安装 ruby​​-2.1.2 时出现一些错误.我是 ruby​​ 的新手,因此需要帮助.请告诉我

Getting few errors while installing ruby-2.1.2 using rvm. I am new to ruby and hence need assistance. Please let me know

安装日志和其他相关信息在这里:日志

Installation log and other relevant information here: log

从问题描述中提供的日志来看,我在系统中安装了ruby 2.1.2.但是,由于安装错误,尝试使用 gem list 列出 gem 时出现错误.更改为 2.1.2 后,即 rvm 使用 2.1.2 并执行 ruby -r openssl -e 'puts OpensSSL::OPENSSL_VERSION' 给出了这个错误:

From the log provided in problem description, I have ruby 2.1.2 installed in the system. However, getting error when tried listing gems with gem list due to installation errors.After changing to 2.1.2 i.e., rvm use 2.1.2 and executing ruby -r openssl -e 'puts OpensSSL::OPENSSL_VERSION' gives this error:

/Users/praveenk.k/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in require': 无法加载此类文件 -- openssl (LoadError) from/Users/praveenk.k/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in require'

/Users/praveenk.k/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- openssl (LoadError) from /Users/praveenk.k/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in require'

推荐答案

Ruby <2.4 与 OpenSSL 1.1 不兼容(例如参见 https://github.com/rbenv/ruby-build/issues/1353).

只是一种预感,但如果您使用的是 Mac + Homebrew,OpenSSL 1.0 最近已被删除,因此任何类似于 brew upgrade openssl 的内容都会将其丢弃.

Just a hunch, but if you're using Mac + Homebrew, OpenSSL 1.0 was recently deleted, so anything along the lines of brew upgrade openssl would trash that.

有几种方法可以解决这个问题:

There are several options to deal with this:

  1. 我通过 asdf 安装了较旧的 Ruby,安装了 LibreSSL(这可能更安全,请参阅 https://security.stackexchange.com/questions/112545/what-are-the-main-advantages-of-using-libressl-in-favor-of-openssl):
  1. I have older Rubies via asdf installed with LibreSSL (which may be safer anyway, see https://security.stackexchange.com/questions/112545/what-are-the-main-advantages-of-using-libressl-in-favor-of-openssl):

$ openssl
OpenSSL> version
LibreSSL 2.8.3

  1. 编译并链接您自己的 OpenSSL 1.0(或者在构建 Ruby 时将编译器标志设置为环境变量 -- https://rvm.io/rubies/installing)
  2. 查看您系统的包管理器是否允许您访问 openssl 1.0 并安装它(最近正在帮助一位同事解决这个问题,但不幸的是,我们目前无法找到适合自制的小桶)

可能还有比这更简单的事情;如果有人有想法,请随时发表评论或提供替代答案.

There might be something less convoluted than that; if someone has ideas, please feel free to comment or give an alternate answer.

编辑

我个人在使用其他一些软件时遇到了这个问题,并发现这解决了它,因为旧的 SSL 版本仍然存在:

I personally ran into this issue with some other software and discovered that this fixed it, since the old SSL version was sitting around still:

brew switch openssl 1.0.2s

只要 Homebrew 没有帮助"为我清理它就应该可以工作.

Should work so long as Homebrew doesn't "helpfully" clean that out for me.

这篇关于安装 ruby​​-2.1.2:无法加载此类文件 -- openssl (LoadError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆