When I run

RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local/Cellar/openssl@3/3.0.1 rbenv install 3.1.0

I get this output:

Downloading ruby-3.1.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.gz
Installing ruby-3.1.0...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.6.2 using ruby-build 20211227-3-gcdc215e)

Inspect or clean up the working tree at /var/folders/ts/k_8jb10136s3zw9k2k08nz3c0000gn/T/ruby-build.20220113093111.65052.FVpqjp
Results logged to /var/folders/ts/k_8jb10136s3zw9k2k08nz3c0000gn/T/ruby-build.20220113093111.65052.log

Last 10 log lines:
The Ruby openssl extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
  --prefix=/Users/jeremy/.rbenv/versions/3.1.0
  --enable-shared
  --with-readline-dir=/usr/local/opt/readline
  --with-openssl-dir=/usr/local/Cellar/openssl@3/3.0.1
  CC=clang
  LDFLAGS=-L/Users/jeremy/.rbenv/versions/3.1.0/lib
  CPPFLAGS=-I/Users/jeremy/.rbenv/versions/3.1.0/include

I don't see any clues in the logs. I have tried lots of things like reinstalling rbenv and openssl, not specifying the configure opts, system updates, installing xcode, and more things from google. Maybe I am missing something.

3

There are 3 best solutions below

2
On

Ruby does not (yet) support OpenSSL 3.0. Implementing support for this newer version is tracked in https://github.com/ruby/openssl/issues/369

For now, you have to use Openssl 1.1 instead, which you can install with

brew install [email protected]
3
On

Hi I also kept running into this on 'Mac OS X 10.15.7 using ruby-build' I had to set both of the following variables at the same time before the rbenv install 3.0.1 command:

OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 3.0.1

The first one tells the compiler to ignore where functions are implicitly declared rather than erroring out when this happens. And the second tells ruby which readline to use (in this case the one installed trough homebrew).

0
On

I eventually just had to uninstall/reinstall rbenv, and that resolved it.

brew uninstall rbenv