# Make dev fails while building from source

**URL:** <https://discuss.hashicorp.com/t/make-dev-fails-while-building-from-source/32413>\
**Category:** Consul\
**Created:** [November 25, 2021, 11:38am UTC](https://discuss.hashicorp.com/t/make-dev-fails-while-building-from-source/32413 "2021-11-25T11:38:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![inout](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/inout/32/23234_2.png) [@inout](https://discuss.hashicorp.com/u/inout)\
**Post date:** [November 25, 2021, 11:38am UTC](https://discuss.hashicorp.com/t/make-dev-fails-while-building-from-source/32413/1 "2021-11-25T11:38:20Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![inout](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/inout/32/23234_2.png) [@inout](https://discuss.hashicorp.com/u/inout)\
**Post date:** [November 25, 2021, 12:00pm UTC](https://discuss.hashicorp.com/t/make-dev-fails-while-building-from-source/32413/2 "2021-11-25T12:00:41Z")

</div>

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

```auto
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 ?

---

<div class="post-metadata">

**Author:** ![aram](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@aram](https://discuss.hashicorp.com/u/aram)\
**Post date:** [November 25, 2021, 12:30pm UTC](https://discuss.hashicorp.com/t/make-dev-fails-while-building-from-source/32413/3 "2021-11-25T12:30:59Z")

</div>

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

> **[Consul by HashiCorp](https://www.consul.io/docs/install#compiling-from-source)**
>
> Installing Consul is simple. You can download a precompiled binary, compile
> from source or run on Kubernetes. This page details these methods.

---

<div class="post-metadata">

**Author:** ![inout](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/inout/32/23234_2.png) [@inout](https://discuss.hashicorp.com/u/inout)\
**Post date:** [November 25, 2021, 1:02pm UTC](https://discuss.hashicorp.com/t/make-dev-fails-while-building-from-source/32413/4 "2021-11-25T13:02:30Z")

</div>

@aram the first sentence reads

> To compile from source, you will need [Go](https://golang.org/) installed and configured properly (including a `GOPATH` environment variable set), as well as a copy of [`git`](https://www.git-scm.com/) in your `PATH`

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

```auto
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 ?

---

<div class="post-metadata">

**Author:** ![aram](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@aram](https://discuss.hashicorp.com/u/aram)\
**Post date:** [November 25, 2021, 1:20pm UTC](https://discuss.hashicorp.com/t/make-dev-fails-while-building-from-source/32413/5 "2021-11-25T13:20:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![inout](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/inout/32/23234_2.png) [@inout](https://discuss.hashicorp.com/u/inout)\
**Post date:** [November 25, 2021, 1:31pm UTC](https://discuss.hashicorp.com/t/make-dev-fails-while-building-from-source/32413/6 "2021-11-25T13:31:24Z")

</div>

@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 !
