Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couldn't require openssl in ruby

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

When I run the gem command it gives error.

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

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

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

I have openssl

$openssl version OpenSSL 1.0.1 14 mar 2012 

How to fix the error?

like image 342
Siva Gnanam Avatar asked Jan 18 '14 07:01

Siva Gnanam


2 Answers

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

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/ to remove

followed by

gem source -a https://rubygems.org/ to read

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

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

like image 53
jspacek Avatar answered Sep 30 '22 11:09

jspacek


I got this error while using debian where openssl was in /usr/bin.

Following the suggestion of jspacek I reconfigured ruby using:

./configure --with-openssl-dir=/usr/bin 

After make and sudo make install I was able to install rails.

like image 21
Toni Letendre Avatar answered Sep 30 '22 12:09

Toni Letendre