Reputation: 361
I am trying to install the mockgen package on go, but I keep receiving a permission denied without knowing why:
go install github.com/golang/mock/[email protected]
Output:
go install github.com/golang/mock/mockgen: copying /tmp/go-build3889221292/b001/exe/a.out: open /home/nocnoc/go/bin/mockgen: permission denied
I have tried using sudo or executing it as root, but I receive this error
sudo: go: command not found
My GOROOT is /usr/local/go and GOPATH is in my home directory. GO1111MODULE is also on.
How can I fix it? Everything else seems to run fine, and only mockgen seems to fail to install.
Upvotes: 2
Views: 2382
Reputation: 361
The issue was the permissions and owners of directories ~/go and ~/go/bin. It was solved by using the chown
command to change the owner of those two directories from root to my user:
drwxr-xr-x 10 root root 4096 Aug 11 2020 go
to
drwxrwxr-x 10 nocnoc nocnoc 4096 Aug 11 2020 go
The permissions and owners of ~/go/bin are the same as those for the directory above.
Upvotes: 3
Reputation: 408
I'm not a Linux expert, but try running:
sudo su
go install github.com/golang/mock/[email protected]
Upvotes: -1