go get ignoring GOPATH

1,721 views
Skip to first unread message

Pat Christopher

unread,
Jul 2, 2012, 8:19:56 PM7/2/12
to golan...@googlegroups.com
Hello,
I'm trying to install external go packages to a location other then GOROOT.  The docs here say, I think, that I can set GOPATH and the go build tool will use this path instead of GOROOT.  However, when I set GOPATH, it is ignored by the go get command.  The command sequence looks like this:

  GOPATH=/home/cpac/golang/gopath/
  go install github.com/ziutek/mymysql/native: open /usr/lib/go/pkg/linux_amd64/github.com/ziutek/mymysql/native.a: permission denied

I'm running go version:
  go version go1.0.2
On ubuntu 12.04

Any ideas on what I'm doing wrong/what else I can try?  My goal is to download go packages to a non-system wide location for a build server.  The build user does not have access to write to GOROOT.  If there's another way to do this, I've love to know that too.

Thanks,
Pat

David Symonds

unread,
Jul 2, 2012, 8:26:54 PM7/2/12
to Pat Christopher, golan...@googlegroups.com
Using bash? Do you need to export it so that launched processes will see it?


Dave.

Kyle Lemons

unread,
Jul 2, 2012, 8:37:10 PM7/2/12
to Pat Christopher, golan...@googlegroups.com
Try deleting the directory in GOROOT.  If it (or any prefix thereof) exists in GOROOT it will override GOPATH.

Patrick Mylund Nielsen

unread,
Jul 2, 2012, 8:39:43 PM7/2/12
to Pat Christopher, David Symonds, golan...@googlegroups.com
Indeed. Try:

export GOPATH=/home/cpac/golang/gopath/

or

GOPATH=/home/cpac/golang/gopath/ go get github.com/ziutek/mymysql/native

To make the export stick, put it in ~/.profile

Pat Christopher

unread,
Jul 2, 2012, 8:47:57 PM7/2/12
to golan...@googlegroups.com
Success!  I deleted the old path from GOROOT as specified in 'go env' and the 'go get' command with an alternative GOPATH succeeded!  

Thanks a bunch everybody, what a fantastic community response!  I almost wish I had more problems :)

Cheers,
Pat

Mue

unread,
Jul 3, 2012, 4:39:13 AM7/3/12
to golang-nuts
On 3 Jul., 02:47, Pat Christopher <coffee...@gmail.com> wrote:

> Success!  I deleted the old path from GOROOT as specified in 'go env' and
> the 'go get' command with an alternative GOPATH succeeded!

One think that many forget when setting their environment up is, that
GOPATH is a PATH, no DIR. This means that it may contain multiple
directories. And here the order is important. The first directory is
the one where 3rd party packages are installed with 'go get'.
Additionally the standard library doesn't has to be in the GOPATH.

See http://mue.tideland.biz/2012/02/go-environment-setup.html.

mue
Reply all
Reply to author
Forward
0 new messages