在 ruby/rbenv 中安装 openssl
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11126105/
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
Installing openssl in ruby / rbenv
提问by Kowshik
I need to use openssl in ruby. How should I install the same? I've installed ruby through rbenv, and am using ubuntu 12.04.
我需要在 ruby 中使用 openssl。我应该如何安装相同的?我已经通过 rbenv 安装了 ruby,并且正在使用 ubuntu 12.04。
kprakasam@ubuntu:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
kprakasam@ubuntu:~$ irb
irb(main):001:0> require 'openssl'
LoadError: no such file to load -- openssl
from /home/kprakasam/.rbenv/versions/1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/kprakasam/.rbenv/versions/1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):1
from /home/kprakasam/.rbenv/versions/1.9.2-p180/bin/irb:12:in `<main>'
回答by s.m.
回答by fguillen
For Mac OSX this is what saved me:
对于 Mac OSX,这就是拯救我的原因:
RUBY_CONFIGURE_OPTS=--with-openssl-dir=<openssl install dir> rbenv install
From the Ruby build wiki
But.. how to find the openssl install dir?:
但是..如何找到openssl安装目录?:
$ brew list openssl
/usr/local/Cellar/openssl/1.0.2d_1/bin/c_rehash
/usr/local/Cellar/openssl/1.0.2d_1/bin/openssl
...
Then the openssl install diris:
然后openssl安装目录是:
/usr/local/Cellar/openssl/1.0.2d_1/
And the ruby installation command ends as this:
并且 ruby 安装命令以这样的方式结束:
RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local/Cellar/openssl/1.0.2d_1/ rbenv install
回答by mseebacher
First, install openssl:
首先,安装openssl:
sudo apt-get -y install build-essential zlib1g-dev libreadline-dev libssl-dev libcurl4-openssl-dev
Afterwards, recompile Ruby.
之后,重新编译 Ruby。
Note: Only fixing the comment from @Nebojsa above
注意:只修复上面@Nebojsa 的评论
回答by Samy Dindane
This might help you: Rails: cannot load such file — openssl.
这可能对您有所帮助:Rails:无法加载此类文件 — openssl。
回答by Hosam Aly
After reading multiple answers to this question, I managed to get it working on macOS 10.15 using the following commands:
在阅读了这个问题的多个答案后,我设法使用以下命令让它在 macOS 10.15 上运行:
brew install homebrew/portable-ruby/portable-openssl
OPENSSL_1_0_DIR=$(brew --prefix portable-openssl)
export CPPFLAGS=-I${OPENSSL_1_0_DIR}/include
export LDFLAGS=-L${OPENSSL_1_0_DIR}/lib
ruby-install ruby 2.2.10 -- --with-openssl-dir=${OPENSSL_1_0_DIR}

