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

Ruby 2.3.1+Rails4环境下bundle install SSL问题求助

解决Mac Ventura 13.3上旧Rails项目(Ruby2.3.x/Rails4)的Bundle SSL错误

核心问题

Ruby 2.3.x依赖的OpenSSL 1.0.x与Mac Ventura的系统证书存储不兼容,且旧版RubyGems/Bundler无法处理rubygems.org的现代SSL要求。以下是分步解决方案:


1. 确认Ruby绑定正确的OpenSSL 1.0版本

先验证当前Ruby的OpenSSL版本:

ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'

输出需为OpenSSL 1.0.x,若不是,重新编译Ruby(禁用预编译包确保绑定指定OpenSSL):

export PKG_CONFIG_PATH=/opt/local/lib/openssl-1.0/pkgconfig
rvm reinstall 2.3.7 --with-openssl-lib=/opt/local/lib/openssl-1.0 --with-openssl-include=/opt/local/include/openssl-1.0 --disable-binary

2. 更新RubyGems到兼容版本

Ruby 2.3.x自带的RubyGems版本过老,无法处理新SSL证书,手动更新到兼容的最新稳定版:

gem update --system 2.7.10

3. 修复SSL证书信任链

Mac Ventura的根证书位置与旧系统不同,将系统根证书导入OpenSSL 1.0的证书库:

sudo security find-certificate -a -p /Library/Keychains/System.keychain > /opt/local/etc/openssl-1.0/cert.pem
sudo security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> /opt/local/etc/openssl-1.0/cert.pem

设置环境变量让Ruby使用该证书文件(可添加到~/.zshrc或~/.bashrc永久生效):

export SSL_CERT_FILE=/opt/local/etc/openssl-1.0/cert.pem

4. 使用适配的Bundler版本

避免用预览版或过新的Bundler,Ruby2.3.x+Rails4最适配的版本是1.17.3:

gem install bundler -v 1.17.3
bundle _1.17.3_ install

5. 适配Xcode版本

Xcode14工具链与Ruby2.3.x不兼容,建议用Xcode10.3,并切换命令行工具:

sudo xcode-select -s /Applications/Xcode_10.3.app/Contents/Developer
xcode-select --install

注意事项

  • 不要将rubygems源改为HTTP,这会导致gem签名验证失败,引发更多依赖问题;
  • 所有操作建议在终端中执行,确保环境变量生效。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 10:17:44