Installing openssl in ruby / rbenv
Solution 1
openssl
needs to be installed on your local machine.
You then need to compile Ruby with openssl support, which is achieved via the --with-openssl-dir
command-line switch.
Maybe this will help you.
Solution 2
For Mac OSX this is what saved me:
RUBY_CONFIGURE_OPTS=--with-openssl-dir=<openssl install dir> rbenv install
From the Ruby build wiki
But.. how to find the openssl install dir?:
$ 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 dir is:
/usr/local/Cellar/openssl/1.0.2d_1/
And the ruby installation command ends as this:
RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local/Cellar/openssl/1.0.2d_1/ rbenv install
Solution 3
First, install openssl:
sudo apt-get -y install build-essential zlib1g-dev libreadline-dev libssl-dev libcurl4-openssl-dev
Afterwards, recompile Ruby.
Note: Only fixing the comment from @Nebojsa above
Solution 4
This might help you: Rails: cannot load such file — openssl.
Solution 5
EDIT: Please note that this answer may be out of date. The issue in question was resolved in v0.8.1.
After reading multiple answers to this question, I managed to get it working on macOS 10.15 using the following commands:
brew install rbenv/tap/[email protected]
OPENSSL_1_0_DIR=$(brew --prefix rbenv/tap/[email protected])
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}
Kowshik
Updated on February 03, 2021Comments
-
Kowshik about 3 years
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.
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>'
-
n8gard over 11 yearsThis is useful if you're using RVM. See the accepted answer if using RBENV.
-
Moxley Stratton about 10 yearsThis worked for me when installing ruby-2.0.0-p451 from source onto Ubuntu-Saucy 13.10.
-
Harry Moreno almost 6 yearsI'll add that my compilation error on OSX mentioned two versions of openssl, I then removed all versions of openssl from brew (uninstall and prune) and reinstalled openssl. Then compiling worked with
ruby-install ruby 2.5.1 -- --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2o_1/
. -
Conor almost 5 yearsFixes
/tmp/ruby-build.20190501225018.25089/ruby-2.6.3/lib/rubygems/core_ext/kernel_require.rb:54:in `require': libssl.so.1.0.0: cannot open shared object file: No such file or directory - /tmp/ruby-build.20190501225018.25089/ruby-2.6.3/.ext/x86_64-linux/openssl.so (LoadError)
on Debian 9 as well -
senor_bacon about 4 yearsThank you! also fixes "Failed to configure openssl. It will not be installed."
-
flpfar over 3 yearsI have upgraded my ubuntu to version 20.04.1 and my ruby stopped working. Using this command and reinstalling the ruby versions on my rbenv did the trick. Thanks!
-
Sanaulla over 2 yearsThen I face the following error -
Error running '__rvm_make -j4'
-
fn control option over 2 years
brew --prefix [email protected]
can be used to get the openssl path, i.e.RUBY_CONFIGURE_OPTS=--with-openssl-dir=$(brew --prefix [email protected])