6

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 Answers3

4

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).

CodeLife
  • 89
  • 6
  • BTW i am using openssl@1.1.1 – CodeLife Jul 22 '22 at 00:51
  • also works with OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" asdf install ruby 3.0.1 – baash05 Dec 08 '22 at 02:09
  • This solution worked for, Install openssl from brew: https://github.com/rbenv/ruby-build/issues/377#issuecomment-21014365 – Lmwangi Jun 09 '23 at 15:31
1

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 openssl@1.1
Holger Just
  • 52,918
  • 14
  • 115
  • 123
  • Thank you for you help but I get the same error if I don't pass RUBY_CONFIGURE_OPTS and it just uses 1.1.1 by default. – jeremy wentworth Jan 13 '22 at 16:13
  • If you still get the same error with openssl 1.1, you need to provide more details from the files mentioned in the error messages or rbenv. For that, you can edit your question. – Holger Just Jan 13 '22 at 16:31
0

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

brew uninstall rbenv

Kidcompassion
  • 91
  • 1
  • 7