Ruby 2.7.4 および 3.0.0 が macOS Big Sur (11.2.3) で失敗する: 宣言されていない識別子 RSA_SSLV23_PADDING
概要
Intel Mac 11.2.3 に Ruby 2.7.4 および Ruby 3 をインストールしようとすると、コンパイル中に次のエラーが表示されます (ruby-install (https://github.com/postmodern/ruby-install) を使用してインストールします)。次のエラーが表示されます。
^
ossl_pkey_rsa.c:942:5: error: use of undeclared identifier 'RSA_SSLV23_PADDING'
DefRSAConst(SSLV23_PADDING);
^
ossl_pkey_rsa.c:877:58: note: expanded from macro 'DefRSAConst'
#define DefRSAConst(x) rb_define_const(cRSA, #x, INT2NUM(RSA_##x))
^
<scratch space>:144:1: note: expanded from here
RSA_SSLV23_PADDING
^
107 warnings and 1 error generated.
make[2]: *** [ossl_pkey_rsa.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make: *** [build-ext] Error 2
!!! Compiling ruby 2.7.4 failed!
また、参考までに:
❯ openssl version
LibreSSL 2.8.3
解決策
すでに RVM を使用して Ruby バージョンをインストールしており、openssl@3 がインストールされている場合は、次のコマンドを実行して修正できます。
rvm install 3.2.2 --with-openssl-dir=$(brew --prefix openssl@3)
openssl@3 をまだインストールしていない場合は、次のコマンドを使用してインストールできます。
$ brew install openssl@3
この Github の問題でこの解決策を見つけました