简体   繁体   中英

Why is GOPATH not recognized by google-cloud-sdk go-app-stager?

When I try to update my appengine project, it gives me an error.

$ sudo gcloud app deploy
ERROR: (gcloud.app.deploy) Staging command [/usr/local/google-cloud-sdk/platform/google_appengine/goroot-1.6/bin/go-app-stager /Users/baz/app/app.yaml /tmp/tmpSZLK/tmpIQ4] failed with return code [1].

------------------------------------ STDOUT ------------------------------------
------------------------------------ STDERR ------------------------------------
2017/07/08 16:22:06 failed analyzing /Users/baz/app: cannot find package "bitbucket.org/foo/bar" in any of:
    ($GOROOT not set)
    ($GOPATH not set)
GOPATH: 

$ echo $GOPATH
/Users/baz/go
$ go env GOPATH
/Users/baz/go

Clearly GOPATH is set (I export it in my .bash_profile).

TL;DR - Do not use sudo for deploying the app.

Longer version

You're running the gcloud app deploy command using sudo . sudo by the nature of the command will not retain the current set of environment variables when running the command as root user.

Try deploying your app engine app without sudo :

gcloud app deploy

If you do need to run you command as sudo (which is a smell that your setup is broken somehow), you can look at this post . Although, I would recommend looking into the possibility of running your command without sudo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM