ruby-install: Unable to require openssl.... We are unable to install any gems.

Hi we ran ruby-install ruby command and it installed ruby 2.1.3 perfectly. But we are unable to progress further due to openssl error. Please guide us.

ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 37 (10 by maintainers)

Most upvoted comments

Leaving this here for any other poor schmuck who has wasted an entire day on this:

Seems like newer versions of OSX deprecated openSSL, leaving lots of stuff broken. You need to reinstall ruby, but specify exactly where your openSSL libraries are for it to be compiled with them. If you’re using rvm then that looks like:

rvm reinstall 2.3.0 --with-openssl-dir=/usr/local/opt/openssl

If you’re using homebrew, then a quick shortcut to where your libraries are is:

brew install openssl
rvm reinstall 2.3.0 --with-openssl-dir=`brew --prefix openssl`

Recently I was struggling with ruby installations due to the recent auto-update in openssl version from 1.0 to 1.1. I found out that the ruby version < 2.4 does not work with openssl version > 1.0.

I was not even able to revert back the openssl to 1.0 version because other libs has dependencies on it.

No other solution except the one given below worked for me:

brew install rbenv/tap/openssl@1.0 rvm reinstall 1.9.3-p551 --with-openssl-dir='/usr/local/opt/openssl@1.0' gem update --system

Now my ruby runs with openssl 1.0 whereas all other libraries are running on the default openssl version 1.1.

ruby-install 0.8.1 has been released, which should fix any issues with 0.8.0 and openssl.

for those looking for a ruby-install/chruby friendly solution, this worked for me:

rm -rf ~/.rubies/ruby-2.6.3
ruby-install ruby-2.6.3 -- --with-openssl-dir=`brew --prefix openssl`

I had to update CPPFLAGS and LDFLAGS to get it working… https://stackoverflow.com/a/61915791/41283

This happens to me too, for some reason ruby-install doesn’t see openssl by default, not sure if that’s something with my OS build or not (ubuntu 14.10),
To fix it I need to add --with-openssl-dir=/usr/include every time,
@collegeimprovements you probably have the same default folder, so you could try installing using

ruby-install ruby 2.1.3 -- --with-openssl-dir=/usr/include

ofcourse I’m assuming that you have openssl installed