安装 ruby​​

编程入门 行业动态 更新时间:2024-10-26 06:36:52
本文介绍了安装 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 不兼容(例如参见 github/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:

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

  • 编译并链接您自己的 OpenSSL 1.0(或者在构建 Ruby 时将编译器标志设置为环境变量 -- rvm.io/rubies/installing)
  • 查看您系统的包管理器是否允许您访问 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​​

    本文发布于:2023-10-16 16:56:27,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1498177.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:ruby

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!