golang / vscode-go

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

command 'go.environment.status' not found [Go extension not working] #3065

Closed sudheer121 closed 9 months ago

sudheer121 commented 9 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.21.4 darwin/arm64 * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. ``` golang.org/x/tools/gopls (devel) golang.org/x/tools/gopls@(devel) 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.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= golang.org/x/sync@v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= golang.org/x/sys@v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/telemetry@v0.0.0-20231011160506-788d5629a052 h1:1baVNneD/IRxmu8JQdBuki78zUqBtZxq8smZXQj0X2Y= golang.org/x/text@v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/tools@v0.14.1-0.20231026192422-8b5abd452b28 h1:5YgdZAe2w0x3Xrjv0+GXrI0jvm7qCQK/ySGFfiEHMfU= 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.21.3 ``` * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. ``` 1.84.2 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e arm64 ``` * Check your installed extensions to get the version of the VS Code Go extension - v0.40.0 * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. - Not working

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file. Share all the settings with the go. or ["go"] or gopls prefixes.

Describe the bug

After installing the go extension, when i click on the go button in the bottom bar, it throws an error go.environment.status not found

https://github.com/golang/vscode-go/assets/31629433/7516b96a-d113-469f-a498-5e79e649fc0d

Steps to reproduce the behavior:

  1. Install go using brew
  2. add the following to bashrc or zshrc
    export GOPATH=$HOME/go
    export GOROOT="$(brew --prefix golang)/libexec"
    export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
    export GOBIN="${GOPATH}/bin"
  3. Install the go extension and click on the Go 1.21.4 button in bottom bar

Screenshots or recordings

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

suutaku commented 9 months ago

same issue

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/john/Library/Caches/go-build'
GOENV='/Users/john/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/john/go-workspace/pkg/mod'
GONOPROXY='github.com/waterbear-search/*'
GONOSUMDB='github.com/waterbear-search/*'
GOOS='darwin'
GOPATH='/Users/john/go-workspace'
GOPRIVATE='github.com/waterbear-search/*'
GOPROXY='https://goproxy.cn'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/john/Desktop/city-base/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/tn/k2gc1_fs6c36vlg0h0gqqghc0000gn/T/go-build2565319687=/tmp/go-build -gno-record-gcc-switches -fno-common'
hyangah commented 9 months ago

Thanks for the report. Can you please run "Developer: Reload Window" command, and see what is printed in the "Go" output channel? Thanks!

suutaku commented 9 months ago

Thanks for the report. Can you please run "Developer: Reload Window" command, and see what is printed in the "Go" output channel? Thanks!

in my case, "Go" output show nothing

suutaku commented 9 months ago

ok, finally, i fixed it by remove all files in GOPATH.

sudheer121 commented 9 months ago

I was working in a monorepo project where only on of the subfolders had go project, so it works now if I open vscode in that go project folder, closing this issue then

zlss commented 8 months ago

好吧,最后,我通过删除 GOPATH 中的所有文件来修复它。

我也是全部删了,重新安装就好了