Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcloud app deploy says: exec: "git": executable file not found in $PATH

I am struggling to deploy a simple Go app to Google App Engine flexible environment. (This is a very cut-down version of a larger app.) When I run gcloud app deploy --project=<projectID> it terminates with an error, and has this in its output:

...
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/[email protected]: 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/[email protected]: 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/[email protected]: 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

It does work if I delete go.mod, but (I think) I need go.mod to compile and test it locally. It does work if I don't import the external package, but of course I need external packages in my larger app. It does work if I choose the standard environment, but I need the flexible environment for my larger app.

How can I deploy this app successfully to a flexible environment?

My local Go is 1.13, and I have the latest version (292.0.0) of gcloud. Apart from go.sum, the contents of my directory is...

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")
}

Thank you.

like image 928
Nik Silver Avatar asked Jul 24 '26 20:07

Nik Silver


1 Answers

IIUC Flexible doesn't support modules (Standard does, go figure!).

You can:

  • either use a custom runtime;
  • or, delete the go.mod|go.sum and try again.

I copied your app.yaml and main.go and it worked for me.

One change to your app.yaml:

runtime: go
env: flex

Then:

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

and:

curl --silent http://localhost:8080
Hello, there

and:

gcloud app deploy --project=${PROJECT}
curl --silent $(\
  gcloud app describe \
  --project=${PROJECT} \
  --format="value(defaultHostname)")
Hello, there
like image 132
DazWilkin Avatar answered Jul 28 '26 02:07

DazWilkin