Open lowang-bh opened 1 year ago
@lowang-bh Is go1.18 the old version before "Choose go environment" and is go1.19.2 the new version you chose in the prompted window? If you open a new integrated terminal and run go version
, do you see go1.18 or go1.19.2?
so I check the $PATH env and find that /usr/local/bin
is before /Users/xxx/sdk/go1.19.2/bin
.
And GOROOT in go env is still the origin one which installed by brew install.
# origin PATH check in macbook's terminal
/Users/xxx/.rd/bin:/Users/xxx/.krew/bin:/usr/local/opt/tcl-tk/bin:/usr/local/opt/sqlite/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/podman/bin:/Library/Apple/usr/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/xxx/go/bin:/Users/xxx/.dapr/bin
# after choose go enviroment and reload vscode, check PATH in vscode's terminal
/Users/xxx/.rd/bin:/Users/xxx/.krew/bin:/usr/local/opt/tcl-tk/bin:/usr/local/opt/sqlite/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/podman/bin:/Library/Apple/usr/bin:/Users/xxx/sdk/go1.19.2/bin:/Users/xxx/.rd/bin:/Users/xxx/.krew/bin:/usr/local/opt/tcl-tk/bin:/usr/local/opt/sqlite/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/xxx/go/bin:/Users/xxx/.dapr/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/xxx/go/bin:/Users/xxx/.dapr/bin
# sometimes, sdk's path is not at PATH env when check PATH in vscode's terminal
/Users/xxx/.rd/bin:/Users/xxx/.krew/bin:/usr/local/opt/tcl-tk/bin:/usr/local/opt/sqlite/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/podman/bin:/Library/Apple/usr/bin:/Users/xxx/.rd/bin:/Users/xxx/.krew/bin:/usr/local/opt/tcl-tk/bin:/usr/local/opt/sqlite/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/xxx/go/bin:/Users/xxx/.dapr/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/xxx/go/bin:/Users/xxx/.dapr/bin
It works well before I use brew install to install some other packages. After that, choose go environment didn't take effects.
even through I set goroot in setting.json with a new go version with "go.goroot": "/Users/xxx/sdk/go1.1y"
, it is still the origin default one at /usr/local/bin/go
And one more thing, I add go sdk bin /Users/xx/sdk/go1.1y/bin
to PATH in .zsh or .bash_profile, but it doesn't appear in PATH when use echo $PATH to check it. what happens to it?
I just remembered https://github.com/microsoft/vscode/issues/99878.
If you happen to have any "terminal.integrated.*"
related settings set, can you please share them for us to test? Thanks!
ps. avoid the "go.goroot"
setting if you want to use the "choose go environment" setting.
ps. avoid the
"go.goroot"
setting if you want to use the "choose go environment" setting.
Yes, I know about it. I just set it to test the vscode's go vesion in terminal. And find it is not the set one. Maybe it's because the system path locate before the sdk path in PATH.
can you please share them for us to test?
I have pasted it in the issue where Share the Go related settings you have added/edited
need. Please take a look. I have replaced username with xxx.
hi, @hyangah , I find that Locate Configured Go Tools
shows the right env about go version, and its go env also is right
Checking configured tools....
GOBIN: undefined
toolsGopath:
gopath: /Users/xxx/go
GOROOT: /Users/xxx/sdk/go1.19.2
PATH: /Users/xxx/sdk/go1.19.2/bin:/Users/xxx/.rd/bin:/Users/xxx/.krew/bin:/Users/xxx/.dapr/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/xxx/go/bin:/usr/local/opt/tcl-tk/bin:/usr/local/opt/sqlite/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/podman/bin:/Library/Apple/usr/bin
PATH (vscode launched with): /Users/xxx/.rd/bin:/Users/xxx/.krew/bin:/Users/xxx/.dapr/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/xxx/go/bin:/usr/local/opt/tcl-tk/bin:/usr/local/opt/sqlite/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/podman/bin:/Library/Apple/usr/bin
go: /Users/xxx/sdk/go1.19.2/bin/go: go version go1.19.2 darwin/amd64
This is certainly a real issue. This is affecting me and multiple people on my team. We're also on osx. I tried a a fresh install of everything (after purging vscode user data). Still won't set the version in the terminal. This has been working without issue for me for years now...
I downgraded vscode to 1.79 and the extension runs the PATH export as expected. So it's either a bug in vscode 1.80, or an interoperability issue with the latest version.
Thanks @glopal Yes, indeed, the new vscode 1.80 removed the settings this extension was sniffing to implement a workaround for a nasty Mac OS issue (https://github.com/golang/vscode-go/blob/3eafcb48099690dbd7f3b170b4b241020c837be7/src/goEnvironmentStatus.ts#L316-L326)
https://code.visualstudio.com/updates/v1_80#_deprecated-shell-and-shellargs-settings-removed
I thought VS Code's environment collection API eventually would do the right thing and this hack was unnecessary. (but it seems that's not true?) I will see if changing the code to use the new setting is needed.
@glopal @lowang-bh Do you have any terminal related settings configured?
I cannot reproduce the issue on my mac and (with vscode 1.80.1) and I observe the fallback code path https://github.com/golang/vscode-go/blob/3eafcb48099690dbd7f3b170b4b241020c837be7/src/goEnvironmentStatus.ts#L335-L337 that calls VS Code's environment variable collection works as expected.
With vscode 1.80.1, if the go extension and the vscode API work as I expect,
After switching the go version, existing terminals should be clearly marked with the warning icons.
Terminals newly launched after reloading vscode should have the path mutation settings applied.
When you see a terminal tab with the warning icon, and hover over it, VS Code will show what environment variables are updated and options to investigate the details or relaunch the terminal. Are you seeing the same behavior?
If not, I think we need to report issues to vscode team.
Also make sure "go.terminal.activateEnvironment"
setting is NOT set to false.
@glopal @lowang-bh Do you have any terminal related settings configured?
I have no special settings about terminal, all is the default.
When you see a terminal tab with the warning icon, and hover over it, VS Code will show what environment variables are updated and options to investigate the details or relaunch the terminal. Are you seeing the same behavior?
I didn't receive this warning of yellow symbol.
Also make sure
"go.terminal.activateEnvironment"
setting is NOT set to false.
I didn't set it, just default. I will test this by setting it to true.
When you see a terminal tab with the warning icon, and hover over it, VS Code will show what environment variables are updated and options to investigate the details or relaunch the terminal. Are you seeing the same behavior?
I didn't receive this warning of yellow symbol.
Also make sure
"go.terminal.activateEnvironment"
setting is NOT set to false.I didn't set it, just default. I will test this by setting it to true.
After "go.terminal.activateEnvironment"
setting to true, the warning appears to me. And I restart the terminal following the warning, but go version didn't changed.
I downgraded vscode to 1.79 and the extension runs the PATH export as expected. So it's either a bug in vscode 1.80, or an interoperability issue with the latest version.
Yes, it also works to me after downgrading to 1.79. The sdk/go1.19.2/bin
is at the first location of PATH. So its a issue of 1.80 @hyangah
in the scenario which switching go version works well, we can see the vscode's terminal runs this command.
If you were using zsh, please follow https://github.com/microsoft/vscode/issues/188235
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.18 darwin/amd64 * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. ``` Build info ---------- golang.org/x/tools/gopls v0.12.4 golang.org/x/tools/gopls@v0.12.4 h1:nce5etAamR46d9oNGxop1aRK5rDQ0NqcY/SHIcyfEKY= 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@v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y= golang.org/x/mod@v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= golang.org/x/sync@v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sys@v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= golang.org/x/text@v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= golang.org/x/tools@v0.10.1-0.20230622221742-0622ad2359a7 h1:5PWemM67wMSPpO0Y3lOPlyvgO3z56YkZRxPFcdd300g= golang.org/x/vuln@v0.0.0-20230110180137-6ad3e3d07815 h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vmU= honnef.co/go/tools@v0.4.2 h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc= mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc= go: go1.20.3 ``` * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. ``` 1.80.0 660393deaaa6d1996740ff4880f1bad43768c814 x64 ``` * Check your installed extensions to get the version of the VS Code Go extension - v0.39.0 * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. ``` Checking configured tools.... GOBIN: undefined toolsGopath: gopath: /Users/xxx/go GOROOT: /Users/xxx/sdk/go1.18 PATH: /Users/xxx/.rd/bin:/Users/xxx/.krew/bin:/usr/local/opt/tcl-tk/bin:/usr/local/opt/sqlite/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/podman/bin:/Library/Apple/usr/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/xxx/go/bin:/Users/xxx/.dapr/bin go: /usr/local/bin/go: go version go1.18 darwin/amd64 gotests: /Users/xxx/go/bin/gotests (version: v1.6.0 built with go: go1.20.3) gomodifytags: /Users/xxx/go/bin/gomodifytags (version: v1.16.0 built with go: go1.20.3) impl: /Users/xxx/go/bin/impl (version: v1.1.0 built with go: go1.20.3) goplay: /Users/xxx/go/bin/goplay (version: v1.0.0 built with go: go1.20.3) dlv: /Users/xxx/go/bin/dlv (version: v1.20.2 built with go: go1.20.3) golangci-lint: /Users/xxx/go/bin/golangci-lint (version: v1.51.0 built with go: go1.20.3) gopls: /Users/xxx/go/bin/gopls (version: v0.12.4 built with go: go1.20.3) go env Workspace Folder (kube-batch): /Users/xxx/go/src/github.com/kubernetes-sigs/kube-batch GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/Users/xxx/Library/Caches/go-build" GOENV="/Users/xxx/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/xxx/go/pkg/mod" GONOPROXY="example.com,git.example.com,coding.example.com" GONOSUMDB="example.com,git.example.com,coding.example.com" GOOS="darwin" GOPATH="/Users/xxx/go" GOPRIVATE="example.com,git.example.com,coding.example.com" GOPROXY="https://goproxy.cn,direct" GOROOT="/Users/xxx/sdk/go1.18" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/Users/xxx/sdk/go1.18/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.18" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/xxx/go/src/github.com/kubernetes-sigs/kube-batch/go.mod" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/qn/0skxqnqd5jl7kgcnp64_t22h0000gp/T/go-build1955381544=/tmp/go-build -gno-record-gcc-switches -fno-common" ```
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 thego.
or["go"]
orgopls
prefixes.Describe the bug
A clear and concise description of what the bug. A clear and concise description of what you expected to happen.
After
brew install qemu
, thechoose go environment
does not take effect. It is still the go vesion at/usr/local/bin/go
, which is the default one installed by brew./usr/local/bin/go
link to another version of go, switching go version still not workSteps to reproduce the behavior:
Choose go environment
at the prompted windowScreenshots or recordings
If applicable, add screenshots or recordings to help explain your problem.