英文:
Permission denied error for 'go.tools'
问题
当我尝试安装Go工具时,我在/usr/local/go/pkg/tool/linux_amd64/cover
处遇到了权限被拒绝的问题。我可以接受这一点,因为它是/usr/local/
目录,需要root
访问权限。
但是我首先怀疑为什么它在我设置GOPATH
为其他位置时仍然尝试安装到这个位置。
$ go version
go version go1.2.1 linux/amd64
$ export GOPATH='/home/vagrant/repos/atlantis-router/vendor'
$ go get code.google.com/p/go.tools/cmd/cover
go install code.google.com/p/go.tools/cmd/cover: open /usr/local/go/pkg/tool/linux_amd64/cover: permission denied
$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/vagrant/repos/atlantis-router/vendor"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"
有人可以指导我解决这个问题吗?可能的原因是什么?
英文:
When I try to install go tools I am getting permission denied for /usr/local/go/pkg/tool/linux_amd64/cover
. I can accept that since it is /usr/local/
directory and need root
access.
But my first doubt is why it is trying to install at this location when I set GOPATH
to some other location.
$ go version
go version go1.2.1 linux/amd64
$ export GOPATH='/home/vagrant/repos/atlantis-router/vendor'
$ go get code.google.com/p/go.tools/cmd/cover
go install code.google.com/p/go.tools/cmd/cover: open /usr/local/go/pkg/tool/linux_amd64/cover: permission denied
$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/vagrant/repos/atlantis-router/vendor"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"
Could anybody guide me solving this issue? What could be the reason?
答案1
得分: 1
Go尝试将该工具安装在$GOTOOLDIR
而不是$GOPATH
中,正如您所看到的,它被设置为/usr/local/go/pkg/tool/linux_amd64
。我这里也是一样的情况。
我猜只需使用sudo运行它,因为该目录中还有其他工具,而且我认为将GOTOOLDIR设置为其他位置可能会搞砸事情。
英文:
Go tries to install that tool in $GOTOOLDIR
, not $GOPATH
, and as you can see it is set to /usr/local/go/pkg/tool/linux_amd64
. Same thing happens to me here.
just run it with sudo, I guess, since there are other tools in that directory, and I think setting GOTOOLDIR to somewhere else might screw things up.
答案2
得分: 0
似乎这是许多用户都遇到的常见问题。我也遇到了同样的情况!第一步是通过以下命令设置Go的环境变量:
echo export GOROOT=/usr/local/go >> ~/.bashrc
echo export GOPATH=$HOME/go >> ~/.bashrc
echo export PATH=$PATH:$GOROOT/bin:$GOPATH/bin >> ~/.bashrc
然后,Go就有了访问权限。
之后运行以下命令,以便系统将您视为管理员:
sudo -s
然后按下Ctrl+Shift+P,选择Go: Instal/Upgrade tools。
这些步骤对我起作用了
英文:
seems like this is a common issue happens for so many users . so happened also to me !
the first step is to set your environment variables for Go by these commands :
echo export GOROOT=/usr/local/go >> ~/.bashrc
echo export GOPATH=$HOME/go >> ~/.bashrc
echo export PATH=$PATH:$GOROOT/bin:$GOPATH/bin >> ~/.bashrc
and then go has the accesses
after that run this command so the system considers you as administrator:
sudo -s
then ctl+Shft+p and select Go: Instal/Upgrade tools
these steps worked for me
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论