From e97975d7ad329779384d627d91e00b5d28041d0b Mon Sep 17 00:00:00 2001 From: Li Zhijian Date: Wed, 30 Sep 2020 16:04:21 +0800 Subject: [PATCH] Makefile: check and use GOBIN environment variable first 'go get' will install binaries into GOBIN when it's set which is not always same with GOPATH/bin this commit can fix below errors: ~/workspace/k8s/helm$ go env | grep -e GOPATH -e GOBIN -e GOROO GOBIN="/home/lizj/go/bin" GOPATH="/home/lizj/gosrc" GOROOT="/home/lizj/go" ~/workspace/k8s/helm$ make build-cross (cd /; GO111MODULE=on go get -u github.com/mitchellh/gox) go: github.com/mitchellh/gox upgrade => v1.0.1 go: github.com/hashicorp/go-version upgrade => v1.2.1 GO111MODULE=on CGO_ENABLED=0 /home/lizj/gosrc/bin/gox -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/helm" -osarch='darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x windows/amd64' -tags '' -ldflags '-w -s -X helm.sh/helm/v3/internal/version.metadata=unreleased -X helm.sh/helm/v3/internal/version.gitCommit=59c77716ad61331da28c37e9430d5f6a3ab23fed -X helm.sh/helm/v3/internal/version.gitTreeState=dirty -extldflags "-static"' ./cmd/helm bash: /home/lizj/gosrc/bin/gox: No such file or directory Makefile:146: recipe for target 'build-cross' failed make: *** [build-cross] Error 127 Signed-off-by: Li Zhijian --- Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 79fc31976..931fe973d 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,12 @@ TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/pp TARGET_OBJS ?= darwin-amd64.tar.gz darwin-amd64.tar.gz.sha256 darwin-amd64.tar.gz.sha256sum linux-amd64.tar.gz linux-amd64.tar.gz.sha256 linux-amd64.tar.gz.sha256sum linux-386.tar.gz linux-386.tar.gz.sha256 linux-386.tar.gz.sha256sum linux-arm.tar.gz linux-arm.tar.gz.sha256 linux-arm.tar.gz.sha256sum linux-arm64.tar.gz linux-arm64.tar.gz.sha256 linux-arm64.tar.gz.sha256sum linux-ppc64le.tar.gz linux-ppc64le.tar.gz.sha256 linux-ppc64le.tar.gz.sha256sum linux-s390x.tar.gz linux-s390x.tar.gz.sha256 linux-s390x.tar.gz.sha256sum windows-amd64.zip windows-amd64.zip.sha256 windows-amd64.zip.sha256sum BINNAME ?= helm -GOPATH = $(shell go env GOPATH) -GOX = $(GOPATH)/bin/gox -GOIMPORTS = $(GOPATH)/bin/goimports +GOBIN = $(shell go env GOBIN) +ifeq ($(GOBIN),) +GOBIN = $(shell go env GOPATH)/bin +endif +GOX = $(GOBIN)/gox +GOIMPORTS = $(GOBIN)/goimports ARCH = $(shell uname -p) ACCEPTANCE_DIR:=../acceptance-testing