Make dev fails while building from source

export GOPATH=/opt/gows

git clone’d consul; make tools

make dev throws the following error

$ make dev
==> Building Consul - OSes: linux, Architectures: amd64
Building sequentially with go install
—> linux/amd64
cp: cannot stat ‘/opt/gows/bin/consul’: No such file or directory
ERROR: Failed to build Consul for linux/amd64
make: *** [GNUmakefile:150: dev-build] Error 1

anyone knows why is this failing ?

line 446 in consul/build-support/functions/20-build.sh has this line

debug_run env CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go install -ldflags "${GOLDFLAGS}" -tags "${GOTAGS}" && cp "${MAIN_GOPATH}/bin/${GOBIN_EXTRA}${binname}" "${outdir}/${binname}"

What is this MAIN_GOPATH ? Why is it there ? What role does it serve ?

Read the first sentence again, I think you missed the base prerequisite.

@aram the first sentence reads

To compile from source, you will need Go installed and configured properly (including a GOPATH environment variable set), as well as a copy of git in your PATH

If you are referring to base prequisite being GOPATH, well that is configured.

GO111MODULE=""
GOARCH="amd64"
GOBIN="/opt/go/bin"
GOCACHE="/home/ops/.cache/go-build"
GOENV="/home/ops/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/opt/gows/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/opt/gows"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.3"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/opt/gows/src/github.com/hashicorp/consul/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2859309562=/tmp/go-build -gno-record-gcc-switches"

There are multiple go projects that are built daily and that includes Vault. So, what gives ?

What in your opinion am i missing ?

I’d appreciate it, if you could tune down your posts. We’re all just members here to try to help each other.

This forum is specifically for helping people use, configure consul not build it from source. Finding a golang forum to help you build will probably lead to a better result.

@aram building consul from source is also about consul and hence the usage of consul forum is appropriate !

If you see my post, i ask about the purpose of MAIN_GOPATH usage in consul/build-support/functions/20-build.sh

You may not know. Perhaps some knowledgeable folks who have gone down that path, may share insight !