You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac系统安装rbenv失败:执行rbenv install 3.2.0报错求助

在MacOS 10.15.7上用rbenv安装Ruby 3.2.0失败的问题解决

初始报错

执行rbenv install 3.2.0时出现构建失败,具体报错如下:

BUILD FAILED (Mac OS X 10.15.7 using ruby-build 20230202)

Inspect or clean up the working tree at /var/folders/yk/clm8vmf15r9cv4hghy2wm6380000gn/T/ruby-build.20230204101926.59465.X5ikLb
Results logged to /var/folders/yk/clm8vmf15r9cv4hghy2wm6380000gn/T/ruby-build.20230204101926.59465.log

Last 10 log lines:
"_strdup", referenced from:
_OSSL_provider_init in p_test-dso-p_test.o
"_strlen", referenced from:
_p_get_params in p_test-dso-p_test.o
ld: symbol(s) not found for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
x86_64-apple-darwin13.4.0-clang -Iinclude -arch x86_64 -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DZLIB -DZLIB_SHARED -DNDEBUG -I/Users/shirinvafaei/.rbenv/versions/3.2.0/include -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -MMD -MF test/buildtest_c_blowfish-bin-buildtest_blowfish.d.tmp -MT test/buildtest_c_blowfish-bin-buildtest_blowfish.o -c -o test/buildtest_c_blowfish-bin-buildtest_blowfish.o test/buildtest_blowfish.c
make[1]: *** [test/p_test.dylib] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [build_sw] Error 2

尝试修复后的报错

执行以下命令重装Command Line Tools后:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
sudo xcode-select -s /Library/Developer/CommandLineTools

再次运行rbenv install 3.2.0仍失败,报错如下:

To follow progress, use 'tail -f /var/folders/yk/clm8vmf15r9cv4hghy2wm6380000gn/T/ruby-build.20230204103403.1653.log' or pass --verbose
Downloading openssl-1.1.1s.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa
Installing openssl-1.1.1s...

BUILD FAILED (Mac OS X 10.15.7 using ruby-build 20230202)

Inspect or clean up the working tree at /var/folders/yk/clm8vmf15r9cv4hghy2wm6380000gn/T/ruby-build.20230204103403.1653.L02zPW
Results logged to /var/folders/yk/clm8vmf15r9cv4hghy2wm6380000gn/T/ruby-build.20230204103403.1653.log

Last 10 log lines:
_dgram_write in bss_dgram.o
_fd_write in bss_fd.o
_fd_puts in bss_fd.o
_sock_write in bss_sock.o
_sock_puts in bss_sock.o
(maybe you meant: _UI_method_get_writer, _RAND_write_file , _PEM_write_bio_PKCS7_stream , _PEM_write_X509_AUX , _PEM_write_PrivateKey , _PEM_write_bio_PrivateKey_traditional , _PEM_write_bio_PrivateKey , _PEM_write_PKCS8_PRIV_KEY_INFO , _PEM_write_bio_PKCS8_PRIV_KEY_INFO , _PEM_write_PKCS8PrivateKey , _PEM_write_bio_PKCS8PrivateKey , _PEM_write_bio , _PEM_X509_INFO_write_bio , _PEM_write_bio_PUBKEY , _PEM_write_DHparams , _PEM_write_EC_PUBKEY , _PEM_write_bio_EC_PUBKEY , _PEM_write_bio_ECPKParameters , _PEM_write_DSA_PUBKEY , _PEM_write_bio_RSA_PUBKEY , _PEM_write_RSAPublicKey , _PEM_write_PKCS7 , _PEM_write_bio_PKCS7 , _PEM_write_X509_CRL , _PEM_write_bio_X509_REQ_NEW , _PEM_write_X509_REQ , _PEM_write_bio_X509 , _PEM_write_PKCS8 , _PEM_write_DHxparams , _PEM_write_DSAparams , _PEM_write_ECPKParameters , _PEM_write_bio_RSAPrivateKey , _UI_method_set_writer , _PEM_write_bio_X509_AUX , _PEM_write_ECPrivateKey , _SMIME_write_CMS , _PEM_write_DSAPrivateKey , _PEM_write_X509 , _PEM_write , _PEM_write_bio_DSAPrivateKey , _PEM_write_bio_X509_CRL , _PEM_write_bio_NETSCAPE_CERT_SEQUENCE , _SMIME_write_PKCS7 , _PEM_ASN1_write , _PEM_ASN1_write_bio , _PEM_write_bio_CMS , _CRYPTO_THREAD_write_lock , _PEM_write_bio_DHxparams , _PEM_write_bio_DSAparams , _PEM_write_RSA_PUBKEY , _TXT_DB_write , _PEM_write_PUBKEY , _BIO_meth_set_write_ex , _BIO_meth_set_write , _BIO_meth_get_write , _PEM_write_bio_DSA_PUBKEY , _BIO_write_ex , _PEM_write_bio_X509_REQ , _PEM_write_bio_Parameters , _PEM_write_bio_ECPrivateKey , _PEM_write_bio_PKCS8 , _PEM_write_X509_REQ_NEW , _PEM_write_bio_DHparams , _BIO_ctrl_get_write_guarantee , _BIO_meth_get_write_ex , _PEM_write_bio_PKCS8PrivateKey_nid , _PEM_write_bio_ASN1_stream , _PEM_write_bio_CMS_stream , _BIO_write , _PEM_write_CMS , _PEM_write_RSAPrivateKey , _PEM_write_NETSCAPE_CERT_SEQUENCE , _PEM_write_PKCS8PrivateKey_nid , _SMIME_write_ASN1 , _PEM_write_bio_RSAPublicKey )
ld: symbol(s) not found for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libcrypto.dylib] Error 1
make: *** [all] Error 2

问题分析

两次报错核心都是链接器找不到x86_64架构对应的符号,根源在于:

  1. MacOS 10.15.7自带的OpenSSL版本过旧,无法满足Ruby 3.2.0对OpenSSL 1.1.1s的编译要求;
  2. 系统自带的clang-4.0版本老旧,编译新库时存在兼容性问题,导致标准库函数符号无法正常链接。

解决步骤

1. 安装Homebrew(未安装则执行)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. 安装新版OpenSSL和clang

用Homebrew提供的更新依赖替换系统旧版本:

brew install openssl llvm

3. 临时设置编译环境变量

指定ruby-build使用Homebrew提供的依赖进行编译:

export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl)"
export CC=$(brew --prefix llvm)/bin/clang
export CXX=$(brew --prefix llvm)/bin/clang++

4. 重新安装Ruby 3.2.0

rbenv install 3.2.0

5. (可选)永久配置环境变量

如果后续还要安装其他Ruby版本,可将上述环境变量添加到shell配置文件(如~/.zshrc或~/.bash_profile):

echo 'export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl)"' >> ~/.zshrc
echo 'export CC=$(brew --prefix llvm)/bin/clang' >> ~/.zshrc
echo 'export CXX=$(brew --prefix llvm)/bin/clang++' >> ~/.zshrc
source ~/.zshrc

内容的提问来源于stack exchange,提问作者Kadaj13

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 15:50:32