gpt4 book ai didi

google-app-engine - gcloud deploy app 找不到导入包 - golang

转载 作者:IT王子 更新时间:2023-10-29 01:41:04 26 4
gpt4 key购买 nike

我已经将我的应用程序的一个版本部署到 GAE,但现在我无法部署更新的版本。当我尝试 gcloud app deploy --version=VERSION 时,我收到一堆错误,显示远程构建找不到我的导入包:

Beginning deployment of service [default]...
Building and pushing image for service [default]
Some files were skipped. Pass `--verbosity=info` to see which ones.
You may also view the gcloud log file, found at
[/home/****/.config/gcloud/logs/2018.04.08/***.log].
Started cloud build [***].
To see logs in the Cloud Console: https://console.cloud.google.com/gcr/builds/****?project=**

------------- REMOTE BUILD OUTPUT --------------------------------------------

starting build "****"

FETCHSOURCE
Fetching storage object: gs://staging.****.appspot.com/us.gcr.io/****/appengine/default.20180408t040210:latest#****
Copying gs://staging.****.appspot.com/us.gcr.io/****/appengine/default.***:latest#***...
/ [1 files][ 6.9 MiB/ 6.9 MiB]
Operation completed over 1 objects/6.9 MiB.
BUILD
Starting Step #0
Step #0: Pulling image: gcr.io/gcp-runtimes/go1builder@sha256:****
Step #0: sha256:***: Pulling from gcp-runtimes/go1-builder
Step #0: Digest: sha256:***
Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/go1-builder@sha256:***
Step #0: main.go:5:2: cannot find package "config" in any of:
Step #0: /usr/local/go/src/config (from $GOROOT)
Step #0: /workspace/_gopath/src/config (from $GOPATH)
Step #0: main.go:6:2: cannot find package "db" in any of:
Step #0: /usr/local/go/src/db (from $GOROOT)
Step #0: /workspace/_gopath/src/db (from $GOPATH)
...
Finished Step #0
ERROR
ERROR: build step 0 "gcr.io/gcp-runtimes/go1builder@sha256:***" failed: exit status 1
-------------------------------------------------------------------------------

ERROR: (gcloud.app.deploy) Cloud build failed. Check logs at https://console.cloud.google.com/gcr/builds/***?project=*** Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details

我已经尝试了几个关于正确设置 GOPATH 的建议,包括以 root 身份运行命令、sudo -E 和设置系统范围的 GOPATH,但到目前为止还没有成功。无论我是在 Cloud Shell 中部署还是在本地设置中运行命令,我都会遇到相同的错误集。如果我设置了错误的 GOPATH,则在进入远程构建阶段之前构建会失败。我也没有更改第一次部署的源代码结构。

我在这上面花了很多时间,感谢任何帮助或建议。谢谢。

编辑:这是我的 app.yaml

runtime: go
env: flex
api_version: go1

env_variables:
APP_DATABASE_CONFIG: "{...}"
APP_CONFIG: "{...}"

同时运行 dev_appserver.py app.yaml 我得到以下输出:dev_appserver.py app.yaml

INFO     2018-04-11 05:20:51,040 application_configuration.py:506] No version specified. Generated version id: 20180411t052051
WARNING 2018-04-11 05:20:51,040 application_configuration.py:163] The Managed VMs runtime is deprecated, please consider migrating your application to use the Flexible runtime. See https://cloud.google.com/appengine/docs/flexible/python/migrating for more details.
INFO 2018-04-11 05:20:51,040 devappserver2.py:105] Skipping SDK update check.
INFO 2018-04-11 05:20:51,102 api_server.py:265] Starting API server at: http://localhost:46211
INFO 2018-04-11 05:21:16,233 dispatcher.py:255] Starting module "default" running at: http://localhost:8080
INFO 2018-04-11 05:21:16,234 admin_server.py:152] Starting admin server at: http://localhost:8000
...

除了开头的警告外,它通常工作正常。我不知道为什么尽管我的 app.yaml 配置它会发出警告,但如果它有帮助,我部署的第一个实例是一个标准项目(Google 演示项目),后来我删除了那个实例。

我想知道远端的那些 GOROOT (/usr/local/go/) 和 GOPATH (/workspace/_gopath/) 来自哪里?这些是默认设置吗?此外,如果有帮助,错误消息中显示的那些 db 和配置包是我的,它们位于 project-root/src 下。

app.yaml 在 project-root/src/web 下。我的 GOPATH 设置为项目根目录。我的 GOROOT 是空的。

最佳答案

您的 Flex app.yaml 文件不应包含

api_version: go1

您可以完全删除该行。只有 App Engine 标准需要它。

Here是一个示例 App Engine Flexible app.yaml 文件。参见 the docs了解您可以在 Flex app.yaml 文件中配置的内容。

关于google-app-engine - gcloud deploy app 找不到导入包 - golang,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49717504/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com