Permission denied when installing go mockgen


I am trying to install the mockgen package on go but keep receiving a permission denied without knowing why

$ go install
go install 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

Any ideas? Everything else seems to run fine, only mockgen seems to fail to install


The issue was the permissions and owners of ~/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


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

Answered By – nocnoc

Answer Checked By – Pedro (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.