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

Ruby版本≥3.1.0安装失败及CocoaPods安装报错问题咨询

Ruby版本兼容问题导致CocoaPods安装失败的解决办法

问题说明

当前Ruby版本为2.6.10.210,安装CocoaPods时触发依赖冲突:

ERROR: 安装CocoaPods时出错:兼容当前Ruby及RubyGems的activesupport(版本要求≥5.0,<8)的最新版本为6.1.7.9。请尝试先执行gem install activesupport -v 6.1.7.9,再重新运行当前命令。activesupport要求Ruby版本≥3.1.0,当前Ruby版本为2.6.10.210。

同时尝试安装Ruby≥3.1.0时出现错误,陷入版本兼容死循环。

解决方案

方案1:成功升级Ruby至≥3.1.0后安装

如果能解决Ruby升级错误,优先采用此方案:

  • 使用RVM管理Ruby版本:
    1. 更新RVM到稳定版:rvm get stable
    2. 安装Ruby 3.1.x稳定版(如3.1.4):rvm install 3.1.4
    3. 设置为默认Ruby版本:rvm use 3.1.4 --default
  • 使用rbenv管理Ruby版本:
    1. 更新rbenv及ruby-build(Homebrew安装的情况下):brew upgrade rbenv ruby-build
    2. 安装Ruby 3.1.4:rbenv install 3.1.4
    3. 设置全局默认版本:rbenv global 3.1.4
    4. 刷新shell环境:eval "$(rbenv init - zsh)"(bash环境替换为eval "$(rbenv init - bash)")
  • 验证版本:执行ruby -v,确认输出为3.1.x及以上
  • 安装指定版本activesupport:gem install activesupport -v 6.1.7.9
  • 安装CocoaPods:gem install cocoapods

方案2:安装兼容Ruby 2.6的CocoaPods旧版本

若Ruby升级无法解决,可尝试安装适配Ruby 2.6的CocoaPods版本(无需升级Ruby):

  • 直接安装兼容版本的CocoaPods:gem install cocoapods -v 1.12.1
    (此版本适配Ruby 2.6,并兼容activesupport 6.1.7.9)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 23:51:15