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

执行bundle install显示安装完成后部分gem缺失的原因及解决办法

问题场景

在macOS Ventura 13.0 (22A380)系统的项目目录下执行bundle install,输出显示eventmachine-1.2.7、ffi-1.15.5、http_parser.rb-0.8.0已安装带原生扩展的版本,但后续执行bundle exec jekyll build时,报错找不到这三个gem:

bundle install输出片段

➜  <my-project> git:(main) ✗ bundle install
Ignoring eventmachine-1.2.7 because its extensions are not built. Try: gem pristine eventmachine --version 1.2.7
Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
Ignoring http_parser.rb-0.8.0 because its extensions are not built. Try: gem pristine http_parser.rb --version 0.8.0
Ignoring sassc-2.4.0 because its extensions are not built. Try: gem pristine sassc --version 2.4.0
# ... 中间省略部分输出 ...
Installing http_parser.rb 0.8.0 with native extensions
Installing eventmachine 1.2.7 with native extensions
Installing ffi 1.15.5 with native extensions
# ... 中间省略部分输出 ...
Bundle complete! 6 Gemfile dependencies, 102 gems now installed.
Gems in the group 'production' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

bundle exec jekyll build报错

➜  <my-project> git:(main) ✗ bundle exec jekyll build
Could not find eventmachine-1.2.7, http_parser.rb-0.8.0, ffi-1.15.5 in any of the sources
Run `bundle install` to install missing gems.
原因分析
  1. 原生扩展构建不完整:安装初期的“ignoring”提示说明这些gem的旧版本存在原生扩展未构建的问题,新安装过程中可能存在隐性构建错误未被抛出,导致Bundler无法识别到可用的gem实例。
  2. ARM架构兼容性问题:如果你的Mac是M系列芯片(arm64架构),这几个旧版本gem的原生扩展对arm64的支持不完善,构建后的文件无法被Ruby正确加载。
  3. Bundler缓存失效:Bundler的gem路径缓存未更新,导致无法读取刚安装的gem信息。
解决步骤
  • 重新构建原生扩展:直接修复有问题的gem扩展
    gem pristine eventmachine --version 1.2.7
    gem pristine ffi --version 1.15.5
    gem pristine http_parser.rb --version 0.8.0
    
  • 卸载后强制重新安装:如果pristine命令失败,彻底清理后重装
    gem uninstall eventmachine -v 1.2.7
    gem uninstall ffi -v 1.15.5
    gem uninstall http_parser.rb -v 0.8.0
    bundle install --force
    
  • ARM架构适配(M系列芯片):通过Rosetta 2以x86模式运行终端后执行命令
    arch -x86_64 zsh
    bundle install
    bundle exec jekyll build
    
  • 重置Bundler缓存:清理旧缓存后重新安装
    bundle clean --force
    bundle install
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 21:25:18