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条回答 默认 最新

相关推荐 更多相似问题