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 1.0.1 14 mar 2012
How to fix the error?
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
gem source -a http://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/.
I got this error while using debian where openssl was in /usr/bin.
I reconfigured ruby using:
./configure --with-openssl-dir=/usr/bin (following the suggestion of jspacek)
After make and sudo make install I was able to install rails.
make sure you have libssl-dev installed:
dpkg -s libssl-dev
if not, install it:
sudo apt-get -y install libssl-dev
I'm leaving this answer for reference to future Googlers:
Type all these commands in your Terminal (OSX) just to be extra sure you've done everything (this is what eventually worked for me)
rvm get stable brew update brew doctor brew install openssl rvm install ruby-2.1 (or whatever version) rvm use (ruby version here) i.e. rvm use ruby-2.1 rvm gemset create NAME i.e. rvm gemset create rails41 gem install rails -v 4.1
As many commenters have pointed out - you need OpenSSL installed before you compile ruby before you install rails (or other gems)
You probably built Ruby from source before installing OpenSSL. Make sure you install it and then try reconfiguring and rebuilding Ruby.
for me it was a case of missing dependencies.
i thought i had all the dependencies required to install ruby, but i too was getting an openSSL and readline error.
i attempted to install ruby with RVM without root privileges which failed but gave me a list of missing dependencies. i then installed the dependencies with a package manager. i then re-attempted to install ruby from source from the beginning, and everything worked OK
the dependencies that were missing, for me, were:
patch libyaml-devel autoconf gcc-c++ readline-devel libffi-devel openssl-devel automake libtool bison sqlite-devel
but they may be different for you.
update: i don't originally remember where exactly i found this list, but a quick search found similar lists on the following pages, which might also help you:
I was getting this error installing Ruby with RVM. Nothing worked. I switched to rbenv. Problem solved!
Rebuilding Ruby after running
sudo apt-get install libssl-dev libreadline-dev libgdbm-dev can solve this issue.
I found this solution here.
Do you use RVM?
If not, try using it and see if it fixes your problem.