![](/img/trans.png)
[英]OpenSSL error installing ruby 2.0.0-p195 on Mac with rbenv
[英]Installing openssl in ruby / rbenv
我需要在 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>'
對於 Mac OSX,這就是拯救我的原因:
RUBY_CONFIGURE_OPTS=--with-openssl-dir=<openssl install dir> rbenv install
但是..如何找到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
...
然后openssl安裝目錄是:
/usr/local/Cellar/openssl/1.0.2d_1/
並且 ruby 安裝命令以這樣的方式結束:
RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local/Cellar/openssl/1.0.2d_1/ rbenv install
首先,安裝openssl:
sudo apt-get -y install build-essential zlib1g-dev libreadline-dev libssl-dev libcurl4-openssl-dev
之后,重新編譯 Ruby。
注意:只修復上面@Nebojsa 的評論
這可能對您有所幫助: Rails:無法加載此類文件 — openssl 。
編輯:請注意,此答案可能已過時。 有問題的問題已在v0.8.1中解決。
在閱讀了這個問題的多個答案后,我設法使用以下命令讓它在 macOS 10.15 上運行:
brew install rbenv/tap/openssl@1.0
OPENSSL_1_0_DIR=$(brew --prefix rbenv/tap/openssl@1.0)
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}
(和其他 linux 發行版)
$ # Display the installation directory:
$ openssl version -d
OPENSSLDIR: "/usr/lib/ssl"
$ # May need to uninstall the previous installation:
$ rbenv uninstall 3.1.2
rbenv: remove /home/aidan/.rbenv/versions/3.1.2? [yN] Y
$ # Then reinstall (using the dir the first step)
$ RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/lib/ssl rbenv install 3.1.2
Installing ruby-3.1.2...
Installed ruby-3.1.2 to /home/aidan/.rbenv/versions/3.1.2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.