Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'go install' trying to install to /usr/lib/go instead of my GOPATH. Permission denied

Tags:

go

I have had some difficulties getting Go up and running correctly on Linux Mint 14. I have a folder ($HOME/develop/gocode) with bin, pkg and src folders as my GOPATH and have the GOPATH environment variable set properly there. I tried installing a certain github repository using go get (https://github.com/jbarham/primegen.go) but Go gave me the error: stat github.com/jbarham/primegen.go: no such file or directory (I think because the repository ends in .go.) Fine, I just cloned it manually, but then when I try to go install one of two executables in that repository (neither one works, but I tried installing primespeed first) I get the following error:

$ cd $GOPATH/src/github.com/jbarham/primegen.go/primespeed
$ go install
go install github.com/jbarham/primegen.go: mkdir /usr/lib/go/pkg/linux_amd64/github.com: permission denied

Why is go trying to install the package there? I've explicitly set my GOPATH variable, and yet it is trying to install packages to /usr/local instead.

I'm not sure if it will help, but here is some other output regarding version and environment:

$ go env
GOROOT="/usr/lib/go"
GOBIN=""
GOARCH="amd64"
GOCHAR="6"
GOOS="linux"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CGO_ENABLED="1"
$ go version
go version go1.0.2
like image 811
Drewmate Avatar asked Jun 04 '13 04:06

Drewmate


2 Answers

export GOPATH=$HOME/go

export GOBIN=$HOME/go/bin

try it.

like image 136
Slash Tu Avatar answered Sep 28 '22 17:09

Slash Tu


  1. Your GOPATH is probably not exported.
  2. Yes, repositories having a .go extension are not 'go gettable'.

Ad 1. (better put into .bashrc or equivalent):

$ export GOPATH=$HOME # just an example

Ad 2. (better raise an issue about the nonsensical repository name):

$ mkdir -p $GOPATH/src/github.com/jbarham
$ cd $GOPATH/src/github.com/jbarham
$ git clone https://github.com/jbarham/primegen.go.git
$ cd primegen.go
$ go install
like image 34
zzzz Avatar answered Sep 28 '22 17:09

zzzz