When running go install
on my cmd
folder I get the error:
go install cmd/go: copying
/var/folders/wh/9y99138n2w1bvcwxz3tbb8zw0000g
n/T/go-build195667123/b150/exe/a.out: open
/usr/local/go/bin/go: permission denied
It looks like my env variables are set correctly:
GOCACHE="/Users/<USER>/Library/Caches/go-build"
GOENV="/Users/<USER>/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/<USER>/src/unbias"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
Here's my directory of my current project: which is inside my go path:
/Users/<USER>/src/unbias
Since it looks like the permission error is not in my project but in my go install path, I am not sure if I should change ownership of such files.
total 37032
drwxr-xr-x 4 root wheel 128B Jul 16 15:53 .
drwxr-xr-x 20 root wheel 640B Jul 16 15:29 ..
-rwxr-xr-x 1 root wheel 15M Jul 16 15:52 go
-rwxr-xr-x 1 root wheel 3.4M Jul 16 15:53 gofmt
My go.mod
is also:
module cmd
go 1.14
It means that either
<PATH_TO>/cmd
permission is not writable or$GOPATH/pkg/cmd/go
is not readable for yourUser
.You may:
sudo chmod -R 777 <PATH_TO>/cmd
govendor
orgo mod
if it's outside ofGOPATH
.$GOPATH
instead (you haven't stated if<PATH_TO>/cmd
inside$GOPATH
<PATH_TO>/cmd
is writable, usesudo
for now and change the ownership to<User>
again bychown
Check the permission on
<PATH_TO>/cmd
or$GOPATH/pkg/cmd/go
again byls -lah <PATH_TO>/cmd
, it should be readable and writable.