sue*_*445 5 ruby google-cloud-platform google-cloud-functions
从几天前开始,云功能的部署一直失败。
source "https://rubygems.org"
ruby "~> 2.7.0"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "google-cloud-firestore"
Run Code Online (Sandbox Code Playgroud)
$ 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
Run Code Online (Sandbox Code Playgroud)
这是bundler 自bundler v2.2.8 以来的回归。
这在bundler v2.2.10 中已修复
所以我希望捆绑程序版本低于 v2.2.8 或高于 v2.2.10。
Cloud Functions 部署 ( gcloud functions deploy) 自动运行bundle install并使用bundler部署任务中安装的内容。
部署任务中的当前捆绑程序版本是 v2.2.9
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"
Run Code Online (Sandbox Code Playgroud)
$ 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)
Run Code Online (Sandbox Code Playgroud)
gcloud functions deploy没有一些参数来更改捆绑程序版本...
https://cloud.google.com/sdk/gcloud/reference/functions/deploy?hl=ja
如何更改Cloud Functions部署中使用的bundler版本?
我也遇到了类似的问题,但是错误输出略有不同。有一件事的共同点是:
Bundler found conflicting requirements for the Ruby version:
Run Code Online (Sandbox Code Playgroud)
经过一些挖掘和故障排除后,我发现 Google Cloud Functions 代表我们锁定了捆绑平台。我不是 Ruby 专家,但我怀疑这会影响 Gemfile 中的信息与 Ruby 版本一起读取的方式。
来自 Google Cloud Functions 的示例日志:
2021-03-10 13:13:01.764 PST
Step #4 - "builder": Done "bundle lock --add-platform x86_64-linux"
Run Code Online (Sandbox Code Playgroud)
解决方案:在本地更新捆绑程序(我更新到2.2.14)。删除您的Gemfile.lock文件并重新bundle install运行以生成Gemfile.lock. 如果有什么需要修复的话,这应该修复依赖关系。
最重要的是,它将更新Platforms您的部分Gemfile.lock以符合 Google 的期望。
就我而言,该平台已从 更新Ruby为x86_64-darwin-19。
或者,如果可能的话,另一种方法可能是仅使用捆绑包更新平台。