vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

bug: tools cannot be installed to configured go.toolsGopath directory

Open hitzhangjie opened this issue 1 year ago • 4 comments

Type: Bug

When I navigate go source code:

  1. build the go1.19,
  2. I want to install the matched gopls, gotests, staticcheck which should be built by go1.19, i think
  3. by default, the tools is installed to ~/go/bin, so I specify go.toolsGopath and try again
  4. the tools still not installed into go.toolsGopath/bin/
  5. I have to manually copy the go1.19 built gopls and other tools into go.toolsGopath/bin/
  6. and vscode-go won't use the tools under go.toolsGopath/bin over ~/go/bin, maybe I didn't added into PATH
  7. I have to configure go.alternateTools like this:
    "gopls": "/path-to/gopath/bin/gopls",
  8. reload the window, all looks ok, but run go: install/update tools no tools is displayed... maybe it's designed to do so.

ok, i think it's a little complex to configure this, actually feels a little mess. I can solve this by mentioned steps, but actually it takes me nearly 1 hour to solve this.

I think we should give 1 simple solution to this. Maybe we also had the solutions, I didn't get that?

Extension version: 0.42.0 VS Code version: Code 1.91.1 (f1e16e1e6214d7c44d078b1f0607b2388f29d729, 2024-07-09T22:06:49.809Z) OS version: Windows_NT x64 10.0.22631 Modes: Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2+

System Info
Item Value
CPUs 13th Gen Intel(R) Core(TM) i9-13900K (32 x 2995)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 63.75GB (36.76GB free)
Process Argv --folder-uri vscode-remote://wsl%2Boraclelinux_8_5/home/zhangjie/github/golang/go
Screen Reader no
VM 0%
Item Value
Remote WSL: OracleLinux_8_5
OS Linux x64 5.15.90.1-microsoft-standard-WSL2+
CPUs 13th Gen Intel(R) Core(TM) i9-13900K (32 x 0)
Memory (System) 31.22GB (26.23GB free)
VM 0%

hitzhangjie avatar Jul 27 '24 10:07 hitzhangjie

looks like this, it says the tools will be installed to /home//github/golang/gopath/bin, but actually not, it is still installed to ~/go/bin. This is apparently a bug.

2024-07-27 18:38:32.034 [info] Running language server gopls(v0.16.1/go1.19)
2024-07-27 18:42:40.322 [info] Tools environment: GOPATH=/home/<username>/github/golang/gopath, GOTOOLCHAIN=auto
2024-07-27 18:42:40.322 [info] Installing 7 tools at /home/<username>/github/golang/gopath/bin
2024-07-27 18:42:40.322 [info]   gopls
2024-07-27 18:42:40.322 [info]   gotests
2024-07-27 18:42:40.322 [info]   gomodifytags
2024-07-27 18:42:40.322 [info]   impl
2024-07-27 18:42:40.322 [info]   goplay
2024-07-27 18:42:40.322 [info]   dlv
2024-07-27 18:42:40.322 [info]   staticcheck
2024-07-27 18:42:40.322 [info] 
2024-07-27 18:42:47.465 [info] Installing golang.org/x/tools/[email protected] (/home/<username>/go/bin/gopls) SUCCEEDED
2024-07-27 18:42:47.494 [info] Try to start language server - installation (enabled: true)
2024-07-27 18:42:47.536 [info] Running language server gopls(v0.15.3/go1.19)
2024-07-27 18:42:50.950 [info] Installing github.com/cweill/gotests/[email protected] (/home/<username>/go/bin/gotests) SUCCEEDED
2024-07-27 18:42:57.390 [info] Installing github.com/fatih/[email protected] (/home/<username>/go/bin/gomodifytags) SUCCEEDED
...

Here's my config:

{
    "go.alternateTools": {
        //go1.19
        "go": "/home/<username>/github/golang/go/bin/go",
        //built by go1.19
        // "dlv": "/home/<username>/github/golang/gopath/bin/dlv",
        // "gofmt": "/home/<username>/github/golang/gopath/bin/gofmt",
        // "gomodifytags": "/home/<username>/github/golang/gopath/bin/gomodifytags",
        // "goplay": "/home/<username>/github/golang/gopath/bin/goplay",
        // "gopls": "/home/<username>/github/golang/gopath/bin/gopls",
        // "gotests": "/home/<username>/github/golang/gopath/bin/gotests",
        // "impl": "/home/<username>/github/golang/gopath/bin/impl",
        // "staticcheck": "/home/<username>/github/golang/gopath/bin/staticcheck"
    },
    // apply GO & PATH settings to the terminal
    "go.terminal.activateEnvironment": true,
    // envvars passed to the tools
    "go.toolsEnvVars": {
        "GOBIN": "/home/<username>/github/golang/gopath/bin",
        "GOPATH": "/home/<username>/github/golang/gopath",
        "GOROOT": "/home/<username>/github/golang/go",
    },
    // `go: install/update the tools`, the tools path
    "go.toolsGopath": "/home/<username>/github/golang/gopath",
    "go.toolsManagement.go": "/home/<username>/github/golang/go/bin/go",
     "go.gopath": "/home/<username>/github/golang/gopath",
    // "go.goroot": "/home/<username>/github/golang/go",
}

hitzhangjie avatar Jul 27 '24 10:07 hitzhangjie

In the integrated terminal, go env output the value of GOBIN is not expected, even though I have set it by goltoolsEnvVars or by GOENV which points to my customized go.env file. I think this is the second bug.

hitzhangjie avatar Jul 27 '24 10:07 hitzhangjie

Finally, I solved this problem. But I think this configuration should be reorganized to make it simpler and clearer.

hitzhangjie avatar Jul 27 '24 14:07 hitzhangjie

Sorry that the log message outputs conflicting info.

I noticed that you are using remote dev setup. Is your settings.json from "Preference: Open Remote Settings (JSON)" or from "Preference: Open Workspace Settings (JSON)" (i.e. workspaceRoot/.vscode)?

hyangah avatar Aug 05 '24 00:08 hyangah

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

gopherbot avatar Sep 05 '24 00:09 gopherbot