Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

go get -> cannot download, /home/azhukov/go is a GOROOT, not a GOPATH

Tags:

go

Good day! I am trying to install gb (vendoring tool for go) in Google Cloud. I try go get and it fails:

azhukov@gce-machine:~$ go get -v github.com/constabulary/gb/...
package github.com/pkg/errors: cannot download, /home/azhukov/go is a GOROOT, not a GOPATH. For more details see: 'go help gopath'

here is env:

azhukov@gce-machine:~$ echo $GOPATH, $GOROOT, $PATH
/home/azhukov/go, , /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/home/azhukov/go/bin

go version:

azhukov@gce-machine:~$ go version
go version go1.8 linux/amd64

go env:

azhukov@gce-machine:~$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/azhukov/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build477416510=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

To me everything looks fine, I don't get why would go get return such error. It is counter-logical.

like image 524
Anton Zhukov Avatar asked Mar 15 '17 12:03

Anton Zhukov


1 Answers

This error is caused by the go tool detecting a Go installation in your GOPATH. It's not telling you that your GOPATH is the GOROOT (that's a different message), it's telling your GOPATH looks like a GOROOT.

Cleaning out your GOPATH and running go get again will fix the error.

like image 168
JimB Avatar answered Nov 15 '22 08:11

JimB