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

在AWS Lambda中使用Ruby调用Firebase时找不到google-protobuf gem求助

解决AWS Lambda中google-cloud-firestore依赖google-protobuf的问题

问题原因

报错提示找不到满足~>3.18版本的google-protobuf,但你已安装3.25.0版本。这是因为版本约束~>3.18要求版本在3.18.x到3.19.0之间(不含3.19),3.25.0超出了这个范围,所以RubyGems判定它不满足依赖要求。

解决步骤

  • 指定兼容版本:在Gemfile中明确添加google-protobuf的版本约束,确保落在要求范围内:

    gem 'google-protobuf', '~> 3.18.0'
    gem 'google-cloud-firestore'
    
  • 重新安装依赖:用bundler将依赖安装到Lambda可识别的vendor/bundle目录:

    bundle install --path vendor/bundle --without development test
    
  • 验证版本:检查安装后的gem版本是否符合要求:

    ls vendor/bundle/ruby/3.2.0/gems/google-protobuf-*
    

    输出应显示google-protobuf-3.18.x格式的目录。

  • 重新打包上传:将包含vendor目录的代码打包成zip,上传到Lambda函数后测试。

额外提示

如果本地是macOS等非Linux系统,直接安装的gem可能在Lambda(Amazon Linux环境)上不兼容,建议用Docker模拟Lambda构建环境安装:

docker run -v "$PWD":/var/task lambci/lambda:build-ruby3.2 bundle install --path vendor/bundle --without development test

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 11:17:13