首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WSL2 Golang安装工具:权限被拒绝

WSL2 Golang安装工具:权限被拒绝
EN

Stack Overflow用户
提问于 2020-10-01 18:11:43
回答 1查看 1.3K关注 0票数 0

我正在尝试在WSL2/Ubuntu中安装golang工具,以便在VSCode中使用它们。每次我想要通过VSCode安装它们时,我都会收到权限被拒绝的消息:

代码语言:javascript
复制
Tools environment: GOPATH=/go
Installing 17 tools at /go/bin in module mode.
  gocode
  gopkgs
  go-outline
  go-symbols
  guru
  gorename
  gotests
  gomodifytags
  impl
  fillstruct
  goplay
  godoctor
  dlv
  gocode-gomod
  godef
  goformat
  golint

Installing github.com/mdempsky/gocode FAILED
Installing github.com/uudashr/gopkgs/v2/cmd/gopkgs FAILED
Installing github.com/ramya-rao-a/go-outline FAILED
Installing github.com/acroca/go-symbols FAILED
Installing golang.org/x/tools/cmd/guru FAILED
Installing golang.org/x/tools/cmd/gorename FAILED
Installing github.com/cweill/gotests/... FAILED
Installing github.com/fatih/gomodifytags FAILED
Installing github.com/josharian/impl FAILED
Installing github.com/davidrjenni/reftools/cmd/fillstruct FAILED
Installing github.com/haya14busa/goplay/cmd/goplay FAILED
Installing github.com/godoctor/godoctor FAILED
Installing github.com/go-delve/delve/cmd/dlv FAILED
Installing github.com/stamblerre/gocode FAILED
Installing github.com/rogpeppe/godef FAILED
Installing winterdrache.de/goformat/goformat FAILED
Installing golang.org/x/lint/golint FAILED

17 tools failed to install.

gocode: failed to install gocode(github.com/mdempsky/gocode): Error: Command failed: /usr/local/go/bin/go get -v github.com/mdempsky/gocode
go: downloading github.com/mdempsky/gocode v0.0.0-20200405233807-4acdcbdea79d
go get github.com/mdempsky/gocode: mkdir /go: permission denied
 undefined  
gopkgs: failed to install gopkgs(github.com/uudashr/gopkgs/v2/cmd/gopkgs): Error: Command failed: /usr/local/go/bin/go get -v github.com/uudashr/gopkgs/v2/cmd/gopkgs
go: downloading github.com/uudashr/gopkgs v1.3.2
go: writing stat cache: mkdir /go: permission denied
go: downloading github.com/uudashr/gopkgs/v2 v2.1.2
go get github.com/uudashr/gopkgs/v2/cmd/gopkgs: mkdir /go: permission denied
 undefined  
go-outline: failed to install go-outline(github.com/ramya-rao-a/go-outline): Error: Command failed: /usr/local/go/bin/go get -v github.com/ramya-rao-a/go-outline
go: downloading github.com/ramya-rao-a/go-outline v0.0.0-20200117021646-2a048b4510eb
go get github.com/ramya-rao-a/go-outline: mkdir /go: permission denied
 undefined  
go-symbols: failed to install go-symbols(github.com/acroca/go-symbols): Error: Command failed: /usr/local/go/bin/go get -v github.com/acroca/go-symbols
go: writing stat cache: mkdir /go: permission denied
go: downloading github.com/acroca/go-symbols v0.1.1
go get github.com/acroca/go-symbols: mkdir /go: permission denied
 undefined  
guru: failed to install guru(golang.org/x/tools/cmd/guru): Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/cmd/guru
go: downloading golang.org/x/tools v0.0.0-20200930213115-e57f6d466a48
go get golang.org/x/tools/cmd/guru: mkdir /go: permission denied
 undefined  
gorename: failed to install gorename(golang.org/x/tools/cmd/gorename): Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/cmd/gorename
go: downloading golang.org/x/tools v0.0.0-20200930213115-e57f6d466a48
go get golang.org/x/tools/cmd/gorename: mkdir /go: permission denied
 undefined  
gotests: failed to install gotests(github.com/cweill/gotests/...): Error: Command failed: /usr/local/go/bin/go get -v github.com/cweill/gotests/...
go: writing stat cache: mkdir /go: permission denied
go: downloading github.com/cweill/gotests v1.5.3
go get github.com/cweill/gotests/...: mkdir /go: permission denied
 undefined  
gomodifytags: failed to install gomodifytags(github.com/fatih/gomodifytags): Error: Command failed: /usr/local/go/bin/go get -v github.com/fatih/gomodifytags
go: writing stat cache: mkdir /go: permission denied
go: downloading github.com/fatih/gomodifytags v1.6.0
go get github.com/fatih/gomodifytags: mkdir /go: permission denied
 undefined  
impl: failed to install impl(github.com/josharian/impl): Error: Command failed: /usr/local/go/bin/go get -v github.com/josharian/impl
go: writing stat cache: mkdir /go: permission denied
go: downloading github.com/josharian/impl v1.0.0
go get github.com/josharian/impl: mkdir /go: permission denied
 undefined  
fillstruct: failed to install fillstruct(github.com/davidrjenni/reftools/cmd/fillstruct): Error: Command failed: /usr/local/go/bin/go get -v github.com/davidrjenni/reftools/cmd/fillstruct
go: downloading github.com/davidrjenni/reftools v0.0.0-20191222082827-65925cf01315
go get github.com/davidrjenni/reftools/cmd/fillstruct: mkdir /go: permission denied
 undefined  
goplay: failed to install goplay(github.com/haya14busa/goplay/cmd/goplay): Error: Command failed: /usr/local/go/bin/go get -v github.com/haya14busa/goplay/cmd/goplay
go: writing stat cache: mkdir /go: permission denied
go: downloading github.com/haya14busa/goplay v1.0.0
go get github.com/haya14busa/goplay/cmd/goplay: mkdir /go: permission denied
 undefined  
godoctor: failed to install godoctor(github.com/godoctor/godoctor): Error: Command failed: /usr/local/go/bin/go get -v github.com/godoctor/godoctor
go: downloading github.com/godoctor/godoctor v0.0.0-20200702010311-8433dcb3dc61
go get github.com/godoctor/godoctor: mkdir /go: permission denied
 undefined  
dlv: failed to install dlv(github.com/go-delve/delve/cmd/dlv): Error: Command failed: /usr/local/go/bin/go get -v github.com/go-delve/delve/cmd/dlv
go: writing stat cache: mkdir /go: permission denied
go: downloading github.com/go-delve/delve v1.5.0
go get github.com/go-delve/delve/cmd/dlv: mkdir /go: permission denied
 undefined  
gocode-gomod: failed to install gocode-gomod(github.com/stamblerre/gocode): Error: Command failed: /usr/local/go/bin/go get -v -d github.com/stamblerre/gocode
go: writing stat cache: mkdir /go: permission denied
go: downloading github.com/stamblerre/gocode v1.0.0
go get github.com/stamblerre/gocode: mkdir /go: permission denied
 undefined  
godef: failed to install godef(github.com/rogpeppe/godef): Error: Command failed: /usr/local/go/bin/go get -v github.com/rogpeppe/godef
go: writing stat cache: mkdir /go: permission denied
go: downloading github.com/rogpeppe/godef v1.1.2
go get github.com/rogpeppe/godef: mkdir /go: permission denied
 undefined  
goformat: failed to install goformat(winterdrache.de/goformat/goformat): Error: Command failed: /usr/local/go/bin/go get -v winterdrache.de/goformat/goformat
go: downloading winterdrache.de/goformat v0.0.0-20180512004123-256ef38c4271
go get winterdrache.de/goformat/goformat: mkdir /go: permission denied
 undefined  
golint: failed to install golint(golang.org/x/lint/golint): Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/lint/golint
go: downloading golang.org/x/lint v0.0.0-20200302205851-738671d3881b
go get golang.org/x/lint/golint: mkdir /go: permission denied
 undefined 

我的主要操作系统是Windows10,我使用VSCode1.49.2结合WSL2和Ubuntu20.04。Go版本是go1.15.2 linux/amd64。需要什么权限才能更改?

EN

回答 1

Stack Overflow用户

发布于 2020-11-03 10:33:04

我刚刚升级到WSL2 (在Windows10上使用Ubuntu20.04),并找到了你的问题,因为我正在绞尽脑汁试图弄清楚为什么我不能运行一个简单的sam构建而不得到权限错误。我发现它是/etc/wsl.conf中配置的权限的一部分。

基于我看到的一个vscode问题,我将wsl.conf文件设置为以下设置:

代码语言:javascript
复制
[automount]
enabled=true
root = /
options="metadata,uid=1000,gid=1000,umask=002,dmask=002,fmask=002"

这些选项将文件的所有者设置为使用uid=1000的用户和使用gid=1000而不是根用户的组。这应该是您登录时所使用的管理员用户,这样您就不必克服所有文件的root所有权。umask、dmask和fmask设置新创建文件的文件权限掩码,basic设置新文件和目录的读/写权限,因此您可以再次安装文件。

我不确定这是否是你遇到的问题,但它看起来非常相似,我花了一个非常困难的周末试图弄清楚它,所以我想把它传递给大家!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64153252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档