profile
viewpoint

Ask questionsinstallation: install go tools failed due to go modules in WSL 2

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • go1.14.7 linux/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • 1.47.3 91899dcef7b8110878ea59626991a18c8a6a1b3e x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.16.1 (installed on ubuntu 20.04 WSL)
  • Run go env to get the go development environment details
    • GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/cikupin/.cache/go-build" GOENV="/home/cikupin/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/cikupin/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/cikupin/Apps/go1.14" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/cikupin/Apps/go1.14/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" 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-build961588625=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

Remote WSL setting

{
    "remote.WSL.debug": false,
    "editor.minimap.enabled": false,
    "go.autocompleteUnimportedPackages": true,
    "go.gopath": "/home/cikupin/go",
    "go.goroot": "/home/cikupin/Apps/go1.14",
    "editor.wordWrap": "on"
}

Describe the bug

I cannot install go tools using WSL as well as install dependecies using go modules.

Steps to reproduce the behavior:

  1. Press ctrl + shift + p
  2. Select Go: Install/Update Tools
  3. Select tools to be installed
  4. Then install tools failed

Screenshots or recordings

Tools environment: GOPATH=/home/cikupin/go
Installing 17 tools at /home/cikupin/go/bin in module mode.
  gocode
  gopkgs
  go-outline
  go-symbols
  guru
  gorename
  gotests
  gomodifytags
  impl
  fillstruct
  goplay
  godoctor
  dlv
  gocode-gomod
  godef
  goimports
  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 golang.org/x/tools/cmd/goimports FAILED
Installing golang.org/x/lint/golint FAILED

17 tools failed to install.

gocode: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v github.com/mdempsky/gocode
go get github.com/mdempsky/gocode: rename /home/cikupin/go/pkg/mod/github.com/mdempsky/gocode@v0.0.0-20200405233807-4acdcbdea79d.tmp-892116712 /home/cikupin/go/pkg/mod/github.com/mdempsky/gocode@v0.0.0-20200405233807-4acdcbdea79d: permission denied
 undefined  
gopkgs: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v github.com/uudashr/gopkgs/v2/cmd/gopkgs
go get github.com/uudashr/gopkgs/v2/cmd/gopkgs: rename /home/cikupin/go/pkg/mod/github.com/uudashr/gopkgs/v2@v2.1.2.tmp-783415105 /home/cikupin/go/pkg/mod/github.com/uudashr/gopkgs/v2@v2.1.2: permission denied
 undefined  
go-outline: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v github.com/ramya-rao-a/go-outline
go get github.com/ramya-rao-a/go-outline: rename /home/cikupin/go/pkg/mod/github.com/ramya-rao-a/go-outline@v0.0.0-20200117021646-2a048b4510eb.tmp-882976360 /home/cikupin/go/pkg/mod/github.com/ramya-rao-a/go-outline@v0.0.0-20200117021646-2a048b4510eb: permission denied
 undefined  
go-symbols: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v github.com/acroca/go-symbols
go: downloading github.com/acroca/go-symbols v0.1.1
go get github.com/acroca/go-symbols: rename /home/cikupin/go/pkg/mod/github.com/acroca/go-symbols@v0.1.1.tmp-514519140 /home/cikupin/go/pkg/mod/github.com/acroca/go-symbols@v0.1.1: permission denied
 undefined  
guru: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v golang.org/x/tools/cmd/guru
go get golang.org/x/tools/cmd/guru: rename /home/cikupin/go/pkg/mod/golang.org/x/tools@v0.0.0-20200811215021-48a8ffc5b207.tmp-281659656 /home/cikupin/go/pkg/mod/golang.org/x/tools@v0.0.0-20200811215021-48a8ffc5b207: permission denied
 undefined  
gorename: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v golang.org/x/tools/cmd/gorename
go get golang.org/x/tools/cmd/gorename: rename /home/cikupin/go/pkg/mod/golang.org/x/tools@v0.0.0-20200811215021-48a8ffc5b207.tmp-118574531 /home/cikupin/go/pkg/mod/golang.org/x/tools@v0.0.0-20200811215021-48a8ffc5b207: permission denied
 undefined  
gotests: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v github.com/cweill/gotests/...
go: downloading github.com/cweill/gotests v1.5.3
go get github.com/cweill/gotests/...: rename /home/cikupin/go/pkg/mod/github.com/cweill/gotests@v1.5.3.tmp-843101448 /home/cikupin/go/pkg/mod/github.com/cweill/gotests@v1.5.3: permission denied
 undefined  
gomodifytags: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v github.com/fatih/gomodifytags
go: downloading github.com/fatih/gomodifytags v1.6.0
go get github.com/fatih/gomodifytags: rename /home/cikupin/go/pkg/mod/github.com/fatih/gomodifytags@v1.6.0.tmp-880674423 /home/cikupin/go/pkg/mod/github.com/fatih/gomodifytags@v1.6.0: permission denied
 undefined  
impl: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v github.com/josharian/impl
go: downloading github.com/josharian/impl v1.0.0
go get github.com/josharian/impl: rename /home/cikupin/go/pkg/mod/github.com/josharian/impl@v1.0.0.tmp-611801750 /home/cikupin/go/pkg/mod/github.com/josharian/impl@v1.0.0: permission denied
 undefined  
fillstruct: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/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: rename /home/cikupin/go/pkg/mod/github.com/davidrjenni/reftools@v0.0.0-20191222082827-65925cf01315.tmp-332642692 /home/cikupin/go/pkg/mod/github.com/davidrjenni/reftools@v0.0.0-20191222082827-65925cf01315: permission denied
 undefined  
goplay: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v github.com/haya14busa/goplay/cmd/goplay
go: downloading github.com/haya14busa/goplay v1.0.0
go get github.com/haya14busa/goplay/cmd/goplay: rename /home/cikupin/go/pkg/mod/github.com/haya14busa/goplay@v1.0.0.tmp-937757042 /home/cikupin/go/pkg/mod/github.com/haya14busa/goplay@v1.0.0: permission denied
 undefined  
godoctor: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/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: rename /home/cikupin/go/pkg/mod/github.com/godoctor/godoctor@v0.0.0-20200702010311-8433dcb3dc61.tmp-967468365 /home/cikupin/go/pkg/mod/github.com/godoctor/godoctor@v0.0.0-20200702010311-8433dcb3dc61: permission denied
 undefined  
dlv: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v github.com/go-delve/delve/cmd/dlv
go: downloading github.com/go-delve/delve v1.5.0
go get github.com/go-delve/delve/cmd/dlv: rename /home/cikupin/go/pkg/mod/github.com/go-delve/delve@v1.5.0.tmp-278137843 /home/cikupin/go/pkg/mod/github.com/go-delve/delve@v1.5.0: permission denied
 undefined  
gocode-gomod: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v -d github.com/stamblerre/gocode
go get github.com/stamblerre/gocode: rename /home/cikupin/go/pkg/mod/github.com/stamblerre/gocode@v1.0.0.tmp-325026275 /home/cikupin/go/pkg/mod/github.com/stamblerre/gocode@v1.0.0: permission denied
 undefined  
godef: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v github.com/rogpeppe/godef
go get github.com/rogpeppe/godef: rename /home/cikupin/go/pkg/mod/github.com/rogpeppe/godef@v1.1.2.tmp-136144262 /home/cikupin/go/pkg/mod/github.com/rogpeppe/godef@v1.1.2: permission denied
 undefined  
goimports: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v golang.org/x/tools/cmd/goimports
go get golang.org/x/tools/cmd/goimports: rename /home/cikupin/go/pkg/mod/golang.org/x/tools@v0.0.0-20200811215021-48a8ffc5b207.tmp-366349652 /home/cikupin/go/pkg/mod/golang.org/x/tools@v0.0.0-20200811215021-48a8ffc5b207: permission denied
 undefined  
golint: failed to install [object Object]: Error: Command failed: /home/cikupin/Apps/go1.14/bin/go get -v golang.org/x/lint/golint
go get golang.org/x/lint/golint: rename /home/cikupin/go/pkg/mod/golang.org/x/lint@v0.0.0-20200302205851-738671d3881b.tmp-257251434 /home/cikupin/go/pkg/mod/golang.org/x/lint@v0.0.0-20200302205851-738671d3881b: permission denied
 undefined
golang/vscode-go

Answer questions hyangah

@cikupin Were you able to install the tools manually? (e.g. GO111MODULE=on go get -v golang.org/x/tools/gopls@latest)

It looks like https://github.com/golang/go/issues/36568. https://golang.org/doc/go1.15#tools "Module cache" section describes a workaround for that issue. Do you mind trying that?

useful!
source:https://uonfu.com/
Github User Rank List