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

Rails应用无法安装新Gem,Bundler版本兼容问题求助

Bundler版本不兼容导致Gem安装失败的解决方法

问题原因

当前使用的Bundler版本(1.16.2)低于Gemfile依赖要求的最低版本(>=1.17.2),其中solargraph明确要求Bundler版本不低于1.17.2,而Rails 5.2.3也要求Bundler >=1.3.0,当前版本无法满足前者的依赖条件。

解决步骤

  1. 安装符合要求的Bundler版本
    在Ruby 2.5.1环境下安装不低于1.17.2的Bundler版本:

    gem install bundler -v '>=1.17.2' --no-document
    

    若需要固定版本,也可以指定具体版本,比如:

    gem install bundler -v '1.17.6' --no-document
    
  2. 在Docker容器中执行安装命令
    修改docker-compose命令,先在容器内安装适配的Bundler版本,再执行bundle install:

    sudo docker-compose run --rm --no-deps web bash -c "gem install bundler -v '>=1.17.2' && bundle install"
    
  3. 验证Bundler版本
    执行以下命令确认当前使用的Bundler版本符合要求:

    bundle -v
    

    输出应显示版本号≥1.17.2。

  4. 可选:锁定Bundler版本到Gemfile.lock
    如果需要团队统一Bundler版本,运行以下命令更新Gemfile.lock中的Bundler版本记录:

    bundle update --bundler
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.11 22:20:29