在 ruby​​ 中不能要求 openssl [英] Couldn't require openssl in ruby

查看:19
本文介绍了在 ruby​​ 中不能要求 openssl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的虚拟机 ubuntu12.04lts 中安装了 openssl.

I have openssl installed in my virtual machine ubuntu12.04lts.

当我运行 gem 命令时,它给出了错误.

When I run the gem command it gives error.

错误:执行 gem 时 (Gem::Exception)
无法要求 openssl.安装 openSSL 并重建 ruby​​(首选)或使用非 HTTPs 源

Error: while executing gem (Gem::Exception)
Unable to require openssl. install openSSL and rebuilt ruby (preferred) or use non HTTPs sources

我还在 irb 模式下测试 require openssl.它给出了错误.

And I also test require openssl in irb mode. it gives error.

加载错误:无法加载此类文件--openssl
来自/usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55 `require'

Loaderror: cannot load such file --openssl
from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55 `require'

我有openssl

$openssl version
OpenSSL 1.0.1 14 mar 2012

如何修复错误?

推荐答案

注意:不推荐调用 ruby​​gems.org - 请谨慎操作!

Note: Calls to rubygems.org are deprecated - proceed with caution!

在从源代码构建 ruby​​2.1.0p0 之后,我在 Mac OSX 上遇到了同样的问题.我已经安装了 openssl.看来 gems 中的引用需要刷新.我跑了:

I had the same issue on Mac OSX after also building ruby2.1.0p0 from the source. I already had openssl installed. It appears that the reference in gems needed refreshing. I ran:

gem source -r https://rubygems.org/ 删除

紧随其后

gem source -a https://rubygems.org/ 阅读

在此之后,我能够成功运行 gems install bundler.

After this, I was able to run gems install bundler successfully.

如果您遇到更多错误,您可以在您下载的 ruby​​ 目录/中尝试 ./configure --with-openssl-dir=/usr/local/ssl.

If you run into further errors, you can try ./configure --with-openssl-dir=/usr/local/ssl in your ruby downloaded dir/.

这篇关于在 ruby​​ 中不能要求 openssl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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