Context
从几天前开始,云功能的部署一直失败。
Gemfile
source "https://rubygems.org"
ruby "~> 2.7.0"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "google-cloud-firestore"
部署脚本
$ gcloud functions deploy my_func --region=us-central1 --memory=128MB --runtime=ruby27
(snip)
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Bundler found conflicting requirements for the Ruby version:
In Gemfile:
Ruby (~> 2.7.0)
google-cloud-firestore was resolved to 2.4.1, which depends on
google-cloud-firestore-v1 (~> 0.0) was resolved to 0.4.0, which depends on
gapic-common (~> 0.3) was resolved to 0.4.0, which depends on
google-protobuf (~> 3.15, >= 3.15.2) was resolved to 3.15.5, which
depends on
Ruby (< 3.1.dev, >= 2.3)
google-cloud-firestore was resolved to 2.4.1, which depends on
google-cloud-firestore-v1 (~> 0.0) was resolved to 0.4.0, which depends on
gapic-common (~> 0.3) was resolved to 0.4.0, which depends on
grpc (~> 1.36) was resolved to 1.36.0, which depends on
Ruby (< 3.1.dev, >= 2.4); Error ID: af32a539
Why?
这是bundler 自bundler v2.2.8 以来的回归。
- https://github.com/rubygems/rubygems/issues/4366 https://github.com/rubygems/rubygems/issues/4366
这在bundler v2.2.10 中已修复
- https://github.com/rubygems/rubygems/blob/master/bundler/CHANGELOG.md#2210-february-15-2021 https://github.com/rubygems/rubygems/blob/master/bundler/CHANGELOG.md#2210-february-15-2021
- https://github.com/rubygems/rubygems/pull/4371 https://github.com/rubygems/rubygems/pull/4371
所以我希望捆绑程序版本低于 v2.2.8 或高于 v2.2.10。
云功能部署(gcloud functions deploy
)自动运行bundle install
和用途bundler
它安装在部署任务中。
部署任务中的当前捆绑程序版本是 v2.2.9
验证码
Gemfile
source "https://rubygems.org"
ruby "~> 2.7.0"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "bundler", "!= 2.2.8", "!= 2.2.9"
部署脚本
$ gcloud functions deploy my_func --region=us-central1 --memory=128MB --runtime=ruby27
(snip)
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (!= 2.2.8, != 2.2.9)
Current Bundler version:
bundler (2.2.9)
主要科目
gcloud functions deploy
没有一些参数来更改捆绑程序版本...
https://cloud.google.com/sdk/gcloud/reference/functions/deploy?hl=ja https://cloud.google.com/sdk/gcloud/reference/functions/deploy?hl=ja
如何更改Cloud Functions部署中使用的bundler版本?