OpenSSL error when installing JRuby with rbenv on MacOS

309 Views Asked by At

I am getting the following error when I run rbenv install jruby-9.4.2.0. The error says OpenSSL isn't available, but as far as I can tell, it is available in multiple places and forms (see "Versions" below). I've tried everything with both OpenSSL 3+ and OpenSSL 1.1. What am I doing wrong?

/var/folders/nm/c044zc5d5b505n42t9v7z4dr0000gt/T/ruby-build.20230926153740.4346.GaTTYO/jruby-9.4.2.0 /var/folders/nm/c044zc5d5b505n42t9v7z4dr0000gt/T/ruby-build.20230926153740.4346.GaTTYO ~
ERROR:  While executing gem ... (Gem::Exception)
    OpenSSL is not available. Install OpenSSL and rebuild Ruby (preferred) or use non-HTTPS sources
    /Users/2b-software-mac/.rbenv/versions/jruby-9.4.2.0/lib/ruby/stdlib/rubygems/request.rb:47:in `configure_connection_for_https'
    /Users/2b-software-mac/.rbenv/versions/jruby-9.4.2.0/lib/ruby/stdlib/rubygems/request/https_pool.rb:6:in `setup_connection'
    ...
    /Users/2b-software-mac/.rbenv/versions/jruby-9.4.2.0/bin/jgem:21:in `<main>'
    org/jruby/RubyKernel.java:1091:in `load'
    gem:4:in `<main>'

I also tried to specifying RUBY_CONFIGURE_OPTS as mentioned here and here, but it didn't work.

  • OpenSSL 3:
    • RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@3)" rbenv install jruby-9.4.2.0
    • RUBY_CONFIGURE_OPTS=--with-openssl-dir=/opt/homebrew/Cellar/openssl@3/3.1.3 rbenv install jruby-9.4.2.0
    • RUBY_CONFIGURE_OPTS=--with-openssl-dir=/opt/local rbenv install jruby-9.4.2.0
  • OpenSSL 1.1:

Relevant Versions

MacOS 13.5.2 (M2)

$ openssl version
OpenSSL 3.1.3 19 Sep 2023 (Library: OpenSSL 3.1.3 19 Sep 2023)

$ gem info openssl 
openssl (3.2.0, 3.0.0)

$ gem info jruby-openssl     
jruby-openssl (0.9.4)

$ java --version
openjdk 21 2023-09-19
OpenJDK Runtime Environment Homebrew (build 21)
OpenJDK 64-Bit Server VM Homebrew (build 21, mixed mode, sharing)

$ rbenv -v
rbenv 1.2.0

$ ruby-build --version
ruby-build 20230919

$ rbenv global
3.1.2

$ ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin22]

$ brew list openssl
/opt/homebrew/Cellar/openssl@3/3.1.3/.bottle/etc/ (7 files)
/opt/homebrew/Cellar/openssl@3/3.1.3/bin/c_rehash
/opt/homebrew/Cellar/openssl@3/3.1.3/bin/openssl
/opt/homebrew/Cellar/openssl@3/3.1.3/include/openssl/ (135 files)
/opt/homebrew/Cellar/openssl@3/3.1.3/lib/libcrypto.3.dylib
/opt/homebrew/Cellar/openssl@3/3.1.3/lib/libssl.3.dylib
/opt/homebrew/Cellar/openssl@3/3.1.3/lib/engines-3/ (3 files)
/opt/homebrew/Cellar/openssl@3/3.1.3/lib/ossl-modules/legacy.dylib
/opt/homebrew/Cellar/openssl@3/3.1.3/lib/pkgconfig/ (3 files)
/opt/homebrew/Cellar/openssl@3/3.1.3/lib/ (4 other files)
/opt/homebrew/Cellar/openssl@3/3.1.3/share/doc/ (798 files)
/opt/homebrew/Cellar/openssl@3/3.1.3/share/man/ (5533 files)
1

There are 1 best solutions below

0
Vishnu Atrai On

brew install openssl

export in ~/.bash_profile

export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

rbenv rehash

rbenv install jruby-9.4.2.0