Ruby 2.7.4 和 3.0.0 在 macOS Big Sur (11.2.3) 上失败:未声明的标识符RSA_SSLV23_PADDING



尝试安装Ruby 2.7.4 &在英特尔Mac 11.2.3上的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类似的情况,只需使用brew卸载openssl@3,而不是安装openssl@1.1

ruby-install负责为您安装OpenSSL依赖,但是在ruby-install中有一个错误,它没有指定需要安装的确切openssl版本。谢天谢地,这个问题已经解决了:

  1. ruby-install升级到>=0.8.3(例如,brew upgrade ruby-install),将ruby的openssl依赖固定在1.1
  2. 安装ruby 3(如ruby-install ruby 3.0.2)

细节:

ruby-install中解决了这个问题(首先通过https://github.com/postmodern/ruby-install/issues/409报告)。Homebrew默认openssl为3.0(最新的主要版本),但Ruby还没有增加对OpenSSL3.0的支持。因此,ruby-install试图使用的openssl依赖项是错误的版本(Ruby仍然是1.1)。

如果您已经使用rvm来安装ruby版本,并且已经安装了openssl@3,您可以通过运行以下命令来修复它:

rvm install 3.2.2 --with-openssl-dir=$(brew --prefix openssl@3)

如果你还没有安装openssl@3,你可以安装它:

$ brew install openssl@3

我在这个Github问题中找到了这个解决方案

最新更新