Building packer causes permission denied error

2019-08-20 03:41发布

问题:

I am trying to build packer and I am getting this error:

go install golang.org/x/tools/cmd/vet: open /usr/lib/go/pkg/tool/linux_amd64/vet: permission denied
Makefile:40: recipe for target 'test' failed
make: *** [test] Error 1

Is the installer trying to access my /usr folder? Should I run this under root? How can I fix this?

回答1:

go vet is special, in that it's a tool that needs to go in GOROOT. In most installations GOROOT is also user writable, but if you installed via a package manager it won't be.

To work around this, you can do this as root to avoid changing any permissions in your GOPATH:

GOPATH=/tmp/tmpGOPATH go get golang.org/x/tools/cmd/vet
rm -rf /tmp/tmpGOPATH

Since vet is a tool provided by the official distribution, not having it installed may be considered a bug in gentoo's go package. The official go binary distribution included the following tools:

addr2line
api
asm
cgo
compile
cover
dist
doc
fix
link
nm
objdump
pack
pprof
tour
trace
vet
yacc


标签: go packer