MacOS で rbenv を使用して JRuby をインストールすると OpenSSL エラーが発生する
概要
rbenv install jruby-9.4.2.0 を実行すると、次のエラーが発生します。エラーには、OpenSSL が利用できないことが示されていますが、私の知る限り、OpenSSL は複数の場所と形式で利用可能です (下記の「バージョン」を参照)。 OpenSSL 3+ と OpenSSL 1.1 の両方ですべてを試しました。私の何が間違っているのでしょうか?
/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>'
こことここで述べたようにRUBY_CONFIGURE_OPTSを指定しようとしましたが、うまくいきませんでした。
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)
解決策
醸造インストールopenssl
~/.bash_profile にエクスポート
import PKG_CONFIG_PATH=“/usr/local/opt/openssl/lib/pkgconfig”
rbenvのリハッシュ
rbenv インストール jruby-9.4.2.0