Compile nomad from source

Hi,

I am trying to compile nomad from source, and running into these errors.
If anyone can help or have previously faced similar issues.

Following https://www.nomadproject.io/guides/install/index.html

$GOPATH = $HOME/go
Nomad location: $GOPATH/src/github.com/hashicorp/nomad

smahajan@smahajan-VirtualBox:~/go/src/github.com/hashicorp/nomad$ make bootstrap
==> Updating build dependencies...
go get -u github.com/kardianos/govendor
go get -u github.com/hashicorp/go-bindata/go-bindata
go get -u github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs
go get -u github.com/a8m/tree/cmd/tree
go get -u github.com/magiconair/vendorfmt/cmd/vendorfmt
go get -u gotest.tools/gotestsum
go get -u github.com/fatih/hclfmt
Installing codec/codecgen@08f7b401aef15f3d544472dd46bf6788cdfe55bf ...
Installing protobuf/protoc-gen-go@v1.2.0 ...
==> Updating linter dependencies...
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
go get -u github.com/client9/misspell/cmd/misspell
smahajan@smahajan-VirtualBox:~/go/src/github.com/hashicorp/nomad$ echo $?
0
smahajan@smahajan-VirtualBox:~/go/src/github.com/hashicorp/nomad$ make dev
--> Formatting vendor/vendor.json
test -x /home/smahajan/go/bin/vendorfmt || go get -u github.com/magiconair/vendorfmt/cmd/vendorfmt
vendorfmt
bash: vendorfmt: command not found
GNUmakefile:211: recipe for target 'vendorfmt' failed
make: *** [vendorfmt] Error 127
smahajan@smahajan-VirtualBox:~/go/src/github.com/hashicorp/nomad$ echo $?
2

Thanks in advance!

Looks like vendorfmt and hclfmt needs to be compiled and installed as well.
Just doing a go get doesn’t work.

Just putting the steps here, if anyone else also faces a similar issue:

  1. go get -u github.com/magiconair/vendorfmt/cmd/vendorfmt
  2. go get github.com/fatih/hclfmt
  3. Go to your $GOPATH where these packages are downloaded, and compile them from source:
    go build -o vendorfmt main.go and go build -o hclfmt main.go
  4. move the binaries to /usr/bin

Now the nomad compilation should work!

Hi @shishir-a412ed! I think this is the hint of what’s wrong:

When you’re working on go projects, you should make sure that $GOPATH/bin is on your $PATH. The go get -u github.com/magiconair/vendorfmt/cmd/vendorfmt will have installed the vendorfmt binary to $GOPATH/bin/vendorfmt.

1 Like

@tgross Perfect! That’s probably the right way to do it. Thanks for the help!