rvm 无法编译 ruby:openssl 检查失败

rvm can't compile ruby: fails openssl check

我正在尝试使用 rvm 在 MacOS 11.6.1 上安装 ruby 2.7.6。我正在指定 brew 安装的 openssl 的位置,但日志显示它不是正确的版本。我觉得一切都很好。我不确定如何进一步排除故障。下面是详细的详细信息。

我执行这条命令:

rvm install 2.7.6 --with-openssl-dir=`brew --prefix openssl@1.1`

RVM 日志的相关部分是

openssl:
    Could not be configured. It will not be installed.
    Check ext/openssl/mkmf.log for more details.

ext/openssl/mkmf.log的相关部分是:

checking for OpenSSL version >= 1.0.1 and < 3.0.0... -------------------- no

"gcc -I../../.ext/include/x86_64-darwin20 -I../.././include -I../.././ext/openssl -I/usr/local/include  -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -g -O2 -fno-common -pipe    -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <openssl/opensslv.h>
4: 
5: /*top*/
6: int conftest_const[(OPENSSL_VERSION_NUMBER >= 0x10001000L) ? 1 : -1];
/* end */

"gcc -I../../.ext/include/x86_64-darwin20 -I../.././include -I../.././ext/openssl -I/usr/local/include  -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -g -O2 -fno-common -pipe    -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <openssl/opensslv.h>
4: 
5: /*top*/
6: int conftest_const[(OPENSSL_VERSION_MAJOR >= 3) ? 1 : -1];
/* end */

--------------------

/Users/germuska/.rvm/src/ruby-2.7.6/ext/openssl/extconf.rb:111: OpenSSL >= 1.0.1, < 3.0.0 or LibreSSL >= 2.5.0 is required
    /Users/germuska/.rvm/src/ruby-2.7.6/ext/openssl/extconf.rb:111:in `<top (required)>'
    ./ext/extmk.rb:214:in `load'
    ./ext/extmk.rb:214:in `block in extmake'
    /Users/germuska/.rvm/src/ruby-2.7.6/lib/mkmf.rb:331:in `open'
    ./ext/extmk.rb:210:in `extmake'
    ./ext/extmk.rb:572:in `block in <main>'
    ./ext/extmk.rb:568:in `each'
    ./ext/extmk.rb:568:in `<main>'

仔细查看后,我意识到我在 /usr/local/include 中有一个 openssl 目录(包含版本 3),它位于我用 [=12= 指定的目录之前的包含路径中]选项。

我通过将 /usr/local/include/openssl 重命名为 /usr/local/include/openssl_hideme 来修复它;之后,扩展编译器找到了我想要的版本。

本来以为命令行中的include会放在路径前面,但是吸取了教训