Couldn't Require Openssl in Ruby

Install OpenSSL Support for self-compiled Ruby Installation

I ran into the same problem. Turns out, the last line of the extconf.rb-generated Makefile reads

ossl.o: $(top_srcdir)/thread_native.h $(top_srcdir)/thread_$(THREAD_MODEL).h

However, top_srcdir isn't defined anywhere in the Makefile.

I figured out where the missing header files were by running

sudo find / -name thread_native.h

which returned (approximately)

~/.rbenv/versions/2.1.0/thread_native.h

There's a line at the top that says something like

topdir = ~/.rbenv/versions/2.1.0/include/ruby-2.1.0

so I just added a line below it pointing to the directory from the find:

top_srcdir = $(topdir)/../..

After all that, I did a make clean in the ext/openssl directory and then make ran without the error.

Installing ruby-2.1.2: Cannot load such file -- openssl (LoadError)

Ruby <2.4 is incompatible with OpenSSL 1.1 (e.g see https://github.com/rbenv/ruby-build/issues/1353).

Just a hunch, but if you're using Mac + Homebrew, OpenSSL 1.0 was recently deleted, so anything along the lines of brew upgrade openssl would trash that.

There are several options to deal with this:

  1. I have older Rubies via asdf installed with LibreSSL (which may be safer anyway, see https://security.stackexchange.com/questions/112545/what-are-the-main-advantages-of-using-libressl-in-favor-of-openssl):
$ openssl
OpenSSL> version
LibreSSL 2.8.3

  1. Compile and link your own OpenSSL 1.0 (or then set compiler flags as environment variables when building Ruby -- https://rvm.io/rubies/installing)
  2. See if your system's package manager allows you to access openssl 1.0 and install with that (was helping a coworker with this recently and we weren't able to find a good keg for homebrew at this time, unfortunately)

There might be something less convoluted than that; if someone has ideas, please feel free to comment or give an alternate answer.

EDIT

I personally ran into this issue with some other software and discovered that this fixed it, since the old SSL version was sitting around still:

brew switch openssl 1.0.2s

Should work so long as Homebrew doesn't "helpfully" clean that out for me.



Related Topics



Leave a reply



Submit