dongnuo2879 2018-04-08 11:49
浏览 75

gcloud deploy应用无法找到导入包-Golang

I have already deployed a version of my app to GAE, but now I have trouble deploying a newer version. When I try gcloud app deploy --version=VERSION, I get a bunch of errors showing that remote build cannot find my import packages:

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
Started cloud build [***].
To see logs in the Cloud Console:****?project=**

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

starting build "****"

Fetching storage object: gs://staging.********/appengine/default.20180408t040210:latest#****
Copying gs://staging.********/appengine/default.***:latest#***...
/ [1 files][  6.9 MiB/  6.9 MiB]                                                
Operation completed over 1 objects/6.9 MiB.                                      
Starting Step #0
Step #0: Pulling image:****
Step #0: sha256:***: Pulling from gcp-runtimes/go1-builder
Step #0: Digest: sha256:***
Step #0: Status: Downloaded newer image for***
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: build step 0 "***" failed: exit status 1

ERROR: ( Cloud build failed. Check logs at***?project=*** Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details

I have tried several suggestions wrt proper setting of the GOPATH, including running command as root, sudo -E, and setting a system-wide GOPATH, no luck so far. I get the same set of errors no matter if I deploy in Cloud Shell or run the command in my local setup. If I set a wrong GOPATH build fails before getting to the remote build stage. I have not changed the source code structure from the first deployment either.

I have spent lot's of time on this, and appreciate any help or advice. Thanks.

EDIT: Here is my app.yaml

runtime: go
env: flex
api_version: go1

   APP_CONFIG: "{...}"

Also running app.yaml I get the following output: app.yaml

INFO     2018-04-11 05:20:51,040] No version specified. Generated version id: 20180411t052051
WARNING  2018-04-11 05:20:51,040] The Managed VMs runtime is deprecated, please consider migrating your application to use the Flexible runtime. See for more details.
INFO     2018-04-11 05:20:51,040] Skipping SDK update check.
INFO     2018-04-11 05:20:51,102] Starting API server at: http://localhost:46211
INFO     2018-04-11 05:21:16,233] Starting module "default" running at: http://localhost:8080
INFO     2018-04-11 05:21:16,234] Starting admin server at: http://localhost:8000

It generally works fine except for that warning at the beginning. I don't know why it gives that warning despite my app.yaml configuration, but if it helps the first instance I deployed was a standard project (the Google demo project), and I deleted that instance later.

I am wondering where those GOROOT (/usr/local/go/) and GOPATH (/workspace/_gopath/) on the remote side come from? Are those the default settings? Also if it helps, those db and config packages shown in error messages are mine, and they are under project-root/src.

app.yaml is under project-root/src/web. My GOPATH is set to project-root. My GOROOT is empty.

  • 写回答

1条回答 默认 最新

  • douzi6992 2018-04-11 12:21

    Your Flex app.yaml file should not include

    api_version: go1

    You can delete the line entirely. It is only needed for App Engine Standard.

    Here is an example App Engine Flexible app.yaml file. See the docs for a reference of what you can configure in a Flex app.yaml file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 安卓13,动态广播无法接受
  • ¥50 docker运行容器端口如何映射(不重启服务、不重建容器)
  • ¥50 基于TwinCAT3实现力传感器的实时读取
  • ¥20 python求解八元一次不定方程,无数解中随机输出几组即可(相关搜索:用python)
  • ¥50 libreoffice导出PPTX到PDF中的错误换行问题
  • ¥15 python实现网页视频下载
  • ¥15 如何通过深度图获得物体的完整、正确点云?
  • ¥15 有没有操作系统适用白丁的经典的书籍,如何解决?(标签-学习)
  • ¥15 Catia V5 R20 64位 安装过程中选择orbix配置创建套接字失败
  • ¥100 C51单片机设计交通灯时出现的问题