gcloud app deploy 说:exec: "git": 在 $PATH 中找不到可执行文件
gcloud app deploy says: exec: "git": executable file not found in $PATH
我正在努力将一个简单的 Go 应用程序部署到 Google App Engine 柔性环境。 (这是一个更大的应用程序的精简版。)当我 运行 gcloud app deploy --project=<projectID>
它以错误终止,并在其输出中有这个:
...
Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/go1-builder@sha256:68b86e4c97438df4c9e36c55ad724079b453398a0a44c29748fb5685eef73895
Step #0: gcr.io/gcp-runtimes/go1-builder@sha256:68b86e4c97438df4c9e36c55ad724079b453398a0a44c29748fb5685eef73895
Step #0: go: github.com/go-stack/stack@v1.8.0: git init --bare in /workspace/_gopath/pkg/mod/cache/vcs/6963ea18be763686e7a9697733dd92bfcc0d45b687afce82da04992523d91cd1: exec: "git": executable file not found in $PATH
Step #0: go: github.com/inconshreveable/log15@v0.0.0-20200109203555-b30bc20e4fd1: git init --bare in /workspace/_gopath/pkg/mod/cache/vcs/fe2a07d0f4107d9daa39043733e909094a5b926cca44d0f7269e7a2185dbef15: exec: "git": executable file not found in $PATH
Step #0: go: github.com/mattn/go-colorable@v0.1.6: git init --bare in /workspace/_gopath/pkg/mod/cache/vcs/f7e99db597f4d2fe3e4509a9af308dace72a13292b505deb909cd0df29c1468a: exec: "git": executable file not found in $PATH
Step #0: go: error loading module requirements
Finished Step #0
如果我删除 go.mod
它确实有效,但是(我认为)我需要 go.mod
来在本地编译和测试它。如果我不导入外部包,它确实有效,但我当然需要在我的大型应用程序中使用外部包。如果我选择标准环境,它确实有效,但我的大型应用程序需要灵活的环境。
如何才能将此应用程序成功部署到灵活的环境中?
我本地的Go是1.13,我有最新版本的gcloud(292.0.0)。除了go.sum
,我目录的内容是...
app.yaml:
runtime: go1.12
env: flex
go.mod:
module mymodulename
go 1.13
require (
github.com/go-stack/stack v1.8.0 // indirect
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1
github.com/mattn/go-colorable v0.1.6 // indirect
)
main.go:
package main
import (
"fmt"
"net/http"
"os"
"github.com/inconshreveable/log15"
)
func main() {
log := log15.New()
http.HandleFunc("/", helloHandler)
port := os.Getenv("PORT")
if port == "" {
port = "8080"
log.Info("Using default port", "port", port)
}
log.Info("Listening", "port", port)
if err := http.ListenAndServe(":"+port, nil); err != nil {
log.Crit("ListenAndServe", "error", err)
os.Exit(1)
}
}
func helloHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello, there")
}
谢谢。
IIUC Flexible 不 支持模块(标准支持,请看图!)。
您可以:
- 要么使用自定义运行时;
- 或者,删除
go.mod
|go.sum
并重试。
我复制了你的 app.yaml
和 main.go
,它对我有用。
你的 app.yaml
的一个变化:
runtime: go
env: flex
然后:
go get github.com/inconshreveable/log15
go run main.go
INFO[05-15|09:33:26] Using default port port=8080
INFO[05-15|09:33:26] Listening port=8080
和:
curl --silent http://localhost:8080
Hello, there
和:
gcloud app deploy --project=${PROJECT}
curl --silent $(\
gcloud app describe \
--project=${PROJECT} \
--format="value(defaultHostname)")
Hello, there
我正在努力将一个简单的 Go 应用程序部署到 Google App Engine 柔性环境。 (这是一个更大的应用程序的精简版。)当我 运行 gcloud app deploy --project=<projectID>
它以错误终止,并在其输出中有这个:
...
Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/go1-builder@sha256:68b86e4c97438df4c9e36c55ad724079b453398a0a44c29748fb5685eef73895
Step #0: gcr.io/gcp-runtimes/go1-builder@sha256:68b86e4c97438df4c9e36c55ad724079b453398a0a44c29748fb5685eef73895
Step #0: go: github.com/go-stack/stack@v1.8.0: git init --bare in /workspace/_gopath/pkg/mod/cache/vcs/6963ea18be763686e7a9697733dd92bfcc0d45b687afce82da04992523d91cd1: exec: "git": executable file not found in $PATH
Step #0: go: github.com/inconshreveable/log15@v0.0.0-20200109203555-b30bc20e4fd1: git init --bare in /workspace/_gopath/pkg/mod/cache/vcs/fe2a07d0f4107d9daa39043733e909094a5b926cca44d0f7269e7a2185dbef15: exec: "git": executable file not found in $PATH
Step #0: go: github.com/mattn/go-colorable@v0.1.6: git init --bare in /workspace/_gopath/pkg/mod/cache/vcs/f7e99db597f4d2fe3e4509a9af308dace72a13292b505deb909cd0df29c1468a: exec: "git": executable file not found in $PATH
Step #0: go: error loading module requirements
Finished Step #0
如果我删除 go.mod
它确实有效,但是(我认为)我需要 go.mod
来在本地编译和测试它。如果我不导入外部包,它确实有效,但我当然需要在我的大型应用程序中使用外部包。如果我选择标准环境,它确实有效,但我的大型应用程序需要灵活的环境。
如何才能将此应用程序成功部署到灵活的环境中?
我本地的Go是1.13,我有最新版本的gcloud(292.0.0)。除了go.sum
,我目录的内容是...
app.yaml:
runtime: go1.12
env: flex
go.mod:
module mymodulename
go 1.13
require (
github.com/go-stack/stack v1.8.0 // indirect
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1
github.com/mattn/go-colorable v0.1.6 // indirect
)
main.go:
package main
import (
"fmt"
"net/http"
"os"
"github.com/inconshreveable/log15"
)
func main() {
log := log15.New()
http.HandleFunc("/", helloHandler)
port := os.Getenv("PORT")
if port == "" {
port = "8080"
log.Info("Using default port", "port", port)
}
log.Info("Listening", "port", port)
if err := http.ListenAndServe(":"+port, nil); err != nil {
log.Crit("ListenAndServe", "error", err)
os.Exit(1)
}
}
func helloHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello, there")
}
谢谢。
IIUC Flexible 不 支持模块(标准支持,请看图!)。
您可以:
- 要么使用自定义运行时;
- 或者,删除
go.mod
|go.sum
并重试。
我复制了你的 app.yaml
和 main.go
,它对我有用。
你的 app.yaml
的一个变化:
runtime: go
env: flex
然后:
go get github.com/inconshreveable/log15
go run main.go
INFO[05-15|09:33:26] Using default port port=8080
INFO[05-15|09:33:26] Listening port=8080
和:
curl --silent http://localhost:8080
Hello, there
和:
gcloud app deploy --project=${PROJECT}
curl --silent $(\
gcloud app describe \
--project=${PROJECT} \
--format="value(defaultHostname)")
Hello, there