我尝试通过 WSL 使用VS Code(v1.38.1),并且在启动任何go工具安装或命令Go:Install / Update tools时,我遇到了权限问题。我尝试重新安装WSL和VS Code,并得到相同的结果。通过嵌入式终端手动输入go get -v github.com/mdempsky/gocode
可以正常工作。
VS Code输出控制台显示以下内容:
Installing 2 tools at /home/username/go/bin
gocode
gopkgs
Installing github.com/mdempsky/gocode FAILED
Installing github.com/uudashr/gopkgs/cmd/gopkgs FAILED
2 tools failed to install.
gocode:
Error: Command failed: /usr/local/go/bin/go get -v github.com/mdempsky/gocode
go: finding github.com/mdempsky/gocode latest
go: extracting github.com/mdempsky/gocode v0.0.0-20190203001940-7fb65232883f
go get github.com/mdempsky/gocode: rename /home/username/go/pkg/mod/github.com/mdempsky/gocode@v0.0.0-20190203001940-7fb65232883f.tmp-492884992 /home/username/go/pkg/mod/github.com/mdempsky/gocode@v0.0.0-20190203001940-7fb65232883f: permission denied
go: finding github.com/mdempsky/gocode latest
go: extracting github.com/mdempsky/gocode v0.0.0-20190203001940-7fb65232883f
go get github.com/mdempsky/gocode: rename /home/username/go/pkg/mod/github.com/mdempsky/gocode@v0.0.0-20190203001940-7fb65232883f.tmp-492884992 /home/username/go/pkg/mod/github.com/mdempsky/gocode@v0.0.0-20190203001940-7fb65232883f: permission denied
gopkgs:
Error: Command failed: /usr/local/go/bin/go get -v github.com/uudashr/gopkgs/cmd/gopkgs
go: extracting github.com/uudashr/gopkgs v2.0.1+incompatible
go get github.com/uudashr/gopkgs/cmd/gopkgs: rename /home/username/go/pkg/mod/github.com/uudashr/gopkgs@v2.0.1+incompatible.tmp-058746657 /home/username/go/pkg/mod/github.com/uudashr/gopkgs@v2.0.1+incompatible: permission denied
go: extracting github.com/uudashr/gopkgs v2.0.1+incompatible
go get github.com/uudashr/gopkgs/cmd/gopkgs: rename /home/username/go/pkg/mod/github.com/uudashr/gopkgs@v2.0.1+incompatible.tmp-058746657 /home/username/go/pkg/mod/github.com/uudashr/gopkgs@v2.0.1+incompatible: permission denied
这是我的go env
输出:
username@PC_username:~$ go env
GOARCH="amd64"
GOCACHE="/home/username/.cache/go-build"
GOENV="/home/username/.config/go/env"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/username/GoProjects"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build120415101=/tmp/go-build -gno-record-gcc-switches"
有人知道可能是什么问题吗?
答案 0 :(得分:0)
这是WSL文件系统实现(Microsoft/WSL#3395, Microsoft/WSL#1956)的已知问题,由VSCode激活的文件监视程序引起。该问题仅在WSL 2中得以解决。
作为一种解决方法,您可以仅从Workspace中排除文件夹pkg和bin。 More info来自官方页面。