Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: Unable to configure Local golang development - go1.22 because go.work is configured as go1.22 but global go is go1.21.3 #63922

Open
raghvenders opened this issue Nov 3, 2023 · 1 comment
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@raghvenders
Copy link
Contributor

raghvenders commented Nov 3, 2023

gopls version

gopls@v0.13.2

go env

Failed to run 'C:\Users\R\golang\go\bin\go.exe env' (cwd: C:\Users\R\golang): Error: Command failed: C:\Users\R\golang\go\bin\go.exe env -json GOPATH GOROOT GOPROXY GOBIN GOMODCACHE
go: downloading go1.22 (windows/amd64)
go: download go1.22 for windows/amd64: toolchain not available

go: downloading go1.22 (windows/amd64)
go: download go1.22 for windows/amd64: toolchain not available

What did you do?

  • I have set up local go lang/go development go1.22 with go.work as go1.22
  • I have not set PATH for bin/go1.22
  • When I open the editor, it is not giving option to configure local go development(go1.22) - Choose go environment is not available.
  • And none of the go commands are working, go version or go env until I get out of the go.work folder, which is configured as 1.22

What did you expect to see?

  • Atleast an option for development editor with the help of gopls to configure local ./bin/go1.22

  • Instead of below error, which is correct

go: download go1.22 for windows/amd64: toolchain not available

but can be more actionable like

go: download go1.22 for windows/amd64: toolchain not available as configured in module or workspace. However you have go1.21.3, make that as your toolchain (lower version) or set PATH for go1.22

However I cannot set lower version as my development of 1.22

What did you see instead?

  • go: download go1.22 for windows/amd64: toolchain not available
  • Failed to run 'C:\Users\R\golang\go\bin\go.exe env' (cwd: C:\Users\R\golang): Error: Command failed: C:\Users\R\golang\go\bin\go.exe env -json GOPATH GOROOT GOPROXY GOBIN GOMODCACHE

Editor and settings

Logs

@raghvenders raghvenders added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Nov 3, 2023
@gopherbot gopherbot added this to the Unreleased milestone Nov 3, 2023
@hyangah
Copy link
Contributor

hyangah commented Nov 3, 2023

@raghvenders There are many different ways, but I think the easiest is to configure your PATH to include the directory where the go1.22 binary exists. Then, when gopls invokes go for the project that specifies go 1.22, the go command will search the PATH and switch to go1.22 binary underneath.

~/godemo$ cat go.mod
module example.com/m

go 1.99999
~/godemo$ ls ./bin
go1.99999
~/godemo$ PATH=$(pwd)/bin:$PATH go version
go1.99999
~/godemo$ cat ./bin/go1.99999
#!/bin/bash

echo "go1.99999"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants