修复在 macOS Monterey 上使用 RVM 安装 Ruby 时出现 openssl@3 错误
尝试了多种解决方案:
实际上,无法安装另一个Ruby版本(3.1.0安装没有问题)在 Apple M1 芯片 macOS Monterey 上。
以下是已安装版本的详细信息:
➜ ~ which openssl
/opt/homebrew/opt/openssl@3/bin/openssl
➜ ~ openssl version -a
OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021)
built on: Tue Dec 14 16:16:25 2021 UTC
platform: darwin64-arm64-cc
options: bn(64,64)
compiler: clang -fPIC -arch arm64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DNDEBUG
OPENSSLDIR: "/opt/homebrew/etc/openssl@3"
ENGINESDIR: "/opt/homebrew/Cellar/openssl@3/3.0.1/lib/engines-3"
MODULESDIR: "/opt/homebrew/Cellar/openssl@3/3.0.1/lib/ossl-modules"
Seeding source: os-specific
CPUINFO: OPENSSL_armcap=0x7f
以下是在 openssl
设置之后添加到 .zshrc
文件中的行:
export PATH="/opt/homebrew/opt/openssl@3/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
使用的 RVM 版本:
➜ ~ rvm -v
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
安装 Ruby 版本时(无论是 3.0) .0 或更低版本,例如 2.6.5),它会引发错误:
➜ ~ rvm install 2.6.5 --with-openssl-dir=`brew --prefix openssl`
ruby-2.6.5 - #removing src/ruby-2.6.5 - please wait
Checking requirements for osx.
Certificates bundle '/opt/homebrew/etc/[email protected]/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/serguei/.rvm/rubies/ruby-2.6.5, this may take a while depending on your cpu(s)...
ruby-2.6.5 - #downloading ruby-2.6.5, this may take a while depending on your connection...
ruby-2.6.5 - #extracting ruby-2.6.5 to /Users/serguei/.rvm/src/ruby-2.6.5 - please wait
ruby-2.6.5 - #configuring - please wait
ruby-2.6.5 - #post-configuration - please wait
ruby-2.6.5 - #compiling - please wait
Error running '__rvm_make -j8',
please read /Users/serguei/.rvm/log/1647291878_ruby-2.6.5/make.log
There has been an error while running make. Halting the installation.
这是创建的日志文件的内容:
+__rvm_make:0> make -j8
BASERUBY = /Users/serguei/.rvm/rubies/ruby-3.1.0/bin/ruby --disable=gems
CC = gcc
LD = ld
LDSHARED = gcc -dynamiclib
CFLAGS = -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -fno-common -pipe
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -DCANONICALIZATION_FOR_MATHN
CPPFLAGS = -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/[email protected]/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/-darwin21 -I./include -I. -I./enc/unicode/12.1.0
DLDFLAGS = -L/opt/homebrew/opt/openssl@3/lib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/[email protected]/lib -install_name /Users/serguei/.rvm/rubies/ruby-2.6.5/lib/libruby.2.6.dylib -compatibility_version 2.6 -current_version 2.6.5 -fstack-protector-strong -framework Security -framework Foundation -fstack-protector-strong -framework Security -framework Foundation
SOLIBS = -lpthread -ldl -lobjc
LANG =
LC_ALL =
LC_CTYPE = UTF-8
Apple clang version 13.1.6 (clang-1316.0.21.2)
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
...
ast.c:132:19: warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
rb_funcall(f, rb_intern("set_encoding"), 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-"));
...
2 warnings generated.
linking shared-object cgi/escape.bundle
6 warnings generated.
linking shared-object psych.bundle
4 warnings generated.
linking shared-object zlib.bundle
422 warnings generated.
linking shared-object date_core.bundle
make: *** [build-ext] Error 2
+__rvm_make:0> return 2
唯一成功安装的版本是 3.1.0
:
➜ ~ rvm list
=* ruby-3.1.0 [ arm64 ]
# => - current
# =* - current && default
# * - default
知道吗?
更新
Tried multiple solutions:
- SO
- RVM GitHub (also participated in the discussions)
Actually, fail to install another Ruby version (3.1.0 is installed without issues) on Apple M1 chip macOS Monterey.
So here are installed versions details:
➜ ~ which openssl
/opt/homebrew/opt/openssl@3/bin/openssl
➜ ~ openssl version -a
OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021)
built on: Tue Dec 14 16:16:25 2021 UTC
platform: darwin64-arm64-cc
options: bn(64,64)
compiler: clang -fPIC -arch arm64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DNDEBUG
OPENSSLDIR: "/opt/homebrew/etc/openssl@3"
ENGINESDIR: "/opt/homebrew/Cellar/openssl@3/3.0.1/lib/engines-3"
MODULESDIR: "/opt/homebrew/Cellar/openssl@3/3.0.1/lib/ossl-modules"
Seeding source: os-specific
CPUINFO: OPENSSL_armcap=0x7f
Here are the lines added to the .zshrc
file following the openssl
setup:
export PATH="/opt/homebrew/opt/openssl@3/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
Used RVM version:
➜ ~ rvm -v
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
When installing a Ruby version (no matter, 3.0.0 or lower, for example, 2.6.5), it raises the error:
➜ ~ rvm install 2.6.5 --with-openssl-dir=`brew --prefix openssl`
ruby-2.6.5 - #removing src/ruby-2.6.5 - please wait
Checking requirements for osx.
Certificates bundle '/opt/homebrew/etc/[email protected]/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/serguei/.rvm/rubies/ruby-2.6.5, this may take a while depending on your cpu(s)...
ruby-2.6.5 - #downloading ruby-2.6.5, this may take a while depending on your connection...
ruby-2.6.5 - #extracting ruby-2.6.5 to /Users/serguei/.rvm/src/ruby-2.6.5 - please wait
ruby-2.6.5 - #configuring - please wait
ruby-2.6.5 - #post-configuration - please wait
ruby-2.6.5 - #compiling - please wait
Error running '__rvm_make -j8',
please read /Users/serguei/.rvm/log/1647291878_ruby-2.6.5/make.log
There has been an error while running make. Halting the installation.
Here is the content of the created log file:
+__rvm_make:0> make -j8
BASERUBY = /Users/serguei/.rvm/rubies/ruby-3.1.0/bin/ruby --disable=gems
CC = gcc
LD = ld
LDSHARED = gcc -dynamiclib
CFLAGS = -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -fno-common -pipe
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -DCANONICALIZATION_FOR_MATHN
CPPFLAGS = -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/[email protected]/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/-darwin21 -I./include -I. -I./enc/unicode/12.1.0
DLDFLAGS = -L/opt/homebrew/opt/openssl@3/lib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/[email protected]/lib -install_name /Users/serguei/.rvm/rubies/ruby-2.6.5/lib/libruby.2.6.dylib -compatibility_version 2.6 -current_version 2.6.5 -fstack-protector-strong -framework Security -framework Foundation -fstack-protector-strong -framework Security -framework Foundation
SOLIBS = -lpthread -ldl -lobjc
LANG =
LC_ALL =
LC_CTYPE = UTF-8
Apple clang version 13.1.6 (clang-1316.0.21.2)
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
...
ast.c:132:19: warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
rb_funcall(f, rb_intern("set_encoding"), 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-"));
...
2 warnings generated.
linking shared-object cgi/escape.bundle
6 warnings generated.
linking shared-object psych.bundle
4 warnings generated.
linking shared-object zlib.bundle
422 warnings generated.
linking shared-object date_core.bundle
make: *** [build-ext] Error 2
+__rvm_make:0> return 2
The only successfully installed version is 3.1.0
:
➜ ~ rvm list
=* ruby-3.1.0 [ arm64 ]
# => - current
# =* - current && default
# * - default
Any idea ?
Update
There is an issue describing possible fixes.
I don't use rvm any more and opted to ASDF.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
对于 ruby 版本
2.6.x
、2.7.x
,也可能适用于3.0.0
。尝试使用[email protected]
安装这些版本。首先,尝试使用自制软件安装 [email protected]
然后尝试安装 ruby 2.6。 5 用这个 openssl
这可能会起作用。
For ruby versions
2.6.x
,2.7.x
, and maybe for3.0.0
also. Try installing these versions with[email protected]
.First, try installing [email protected] with homebrew
Then try installing ruby 2.6.5 with this openssl
This may work.
这对我有用:
This worked for me:
尝试
try
我对 Ruby 3.3.1 做了同样的事情
I did the same with Ruby 3.3.1
这对我在运行 Sonoma 的 M1 MacBook Pro 上有效:
PKG_CONFIG_PATH="$(brew --prefix [电子邮件受保护] )/lib/pkgconfig"rvm 安装 2.5.5 --with-openssl-dir=$(brew --prefix [电子邮件受保护])
我不确定为什么
--with-openssl-dir
似乎不够就像 RVM 的错误一样This worked for me on an M1 MacBook Pro running Sonoma:
PKG_CONFIG_PATH="$(brew --prefix [email protected])/lib/pkgconfig" rvm install 2.5.5 --with-openssl-dir=$(brew --prefix [email protected])
I am not sure why
--with-openssl-dir
isn't sufficient, seems like a bug with RVM只需重新安装具有所需 openssl 版本的冲突 gem 即可。
我遇到了类似的问题,json-jwt lib 正在寻找 openssl@3。无需重新安装整个 ruby,只需重新安装 json-jwt gem。
Just re-install conflicting gem with required openssl version.
I faced similar issue, json-jwt lib was looking for openssl@3. Instead of reinstalling entire ruby, just reinstalled json-jwt gem.
您是否尝试过 rvm install 2.6.5 --with-openssl-dir=/opt/openssl ?
上次它对我有用
Have you tried
rvm install 2.6.5 --with-openssl-dir=/opt/openssl
?Last time it worked for me