golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.79k stars 729 forks source link

Linux to Windows remote: Go commands not available #3183

Closed xswordsx closed 4 months ago

xswordsx commented 4 months ago

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

Version Information
* Run `go version` to get version of Go from _the VS Code integrated terminal_. - `go version go1.22.0 windows/amd64` * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. - ``` Build info ---------- golang.org/x/tools/gopls v0.14.2 golang.org/x/tools/gopls@v0.14.2 h1:sIw6vjZiuQ9S7s0auUUkHlWgsCkKZFWDHmrge8LYsnc= github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y= golang.org/x/mod@v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/sync@v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= golang.org/x/sys@v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/telemetry@v0.0.0-20231114163143-69313e640400 h1:brbkEFfGwNGAEkykUOcryE/JiHUMMJouzE0fWWmz/QU= golang.org/x/text@v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/tools@v0.14.1-0.20231114185516-c9d3e7de13fd h1:Oku7E+OCrXHyst1dG1z10etCTxewCHXNFLRlyMPbh3w= golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU= honnef.co/go/tools@v0.4.5 h1:YGD4H+SuIOOqsyoLOpZDWcieM28W47/zRO7f+9V3nvo= mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc= go: go1.22.0 ``` * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. - ``` 1.86.1 31c37ee8f63491495ac49e43b8544550fbae4533 x64 ``` * Check your installed extensions to get the version of the VS Code Go extension - ``` v0.41.0 ``` * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. - ``` command 'go.locate.tools' not found ``` * Additional information - _Remote Development_ extension (`ms-vscode-remote.vscode-remote-extensionpack`) version: `v0.25.0` - OpenSSH server installed from the _Optional features_ section of _Windows Settings_

Share the Go related settings you have added/edited

"go.toolsManagement.autoUpdate": true,
"go.useLanguageServer": true,
"go.testTimeout": "5s",
"go.gopath": "/home/<USER>/projects/go",
"[go]": {
    "editor.tabSize": 8,
    "editor.codeActionsOnSave": {
        "source.organizeImports": "explicit"
    },
},
"go.buildTags": "integration",

Describe the bug

When trying to run any of the Go tools from my VSCode "client side" (Linux) on my VSCode "server side" (Windows) all I get are errors command 'go.xxx.yyy' not found (e.g. go.locate.tools).

What I expected was to be able to run the Go tools, regardless of OS-es.

Steps to reproduce the behavior:

  1. Run a VSCode instance on a Windows machine with OpenSSH setup.
  2. Connect to the instance from (1) via a VSCode instance running on Linux.
  3. Try to run a Go-related command (e.g. Go: Restart Language Server).

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

xswordsx commented 4 months ago

I've a hunch that this has something to do with C:\ being interpreted as a relative path, rather than an absolute one, but I can't be certain.

hyangah commented 4 months ago

In remote setup, this extension runs on the remote side. https://code.visualstudio.com/docs/remote/remote-overview

When trying to run any of the Go tools from my VSCode "client side" (Linux) on my VSCode "server side" (Windows)

Assuming the server side is "windows", the GOPATH configured doesn't seem right to me.

Can you try with the setting without "go.gopath": "/home/<USER>/projects/go"?

xswordsx commented 4 months ago

That fixed it. Thanks! I thought the settings.json file was only applied on the client-side, but it seems to have been applied on the server as well (I did also have syncing of settings enabled, so I guess I should've seen that one coming).