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

Worked example

brew install rbenv/tap/[email protected]
rvm install 2.1.2 -C --with-openssl-dir=`brew --prefix [email protected]`

It's from https://github.com/rvm/rvm/issues/4819#issuecomment-595644550


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.