-
Notifications
You must be signed in to change notification settings - Fork 752
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
Failed to find the "go" binary from PATH #971
Comments
Thanks for finding the references to the latest vscode work towards this issue. Looks like the process environment population got unstable in the recent releases of vscode. :-( Until vscode team sorts out this and directs extension authors, let's make a link to the reference issue and recommend the "Reload the window" command. |
Change https://golang.org/cl/276492 mentions this issue: |
Change https://golang.org/cl/276493 mentions this issue: |
This is a frequently used installation path for custom executables including go in newer mac, but this isn't included in system default PATH. Many users add this in their login shell, or /etc/paths.d, but when VSCode fails to load the environment, the users end up with the incomplete PATH, and go couldn't be found. Since this problem got worsened recently, add /usr/local/bin/go to the fallback path list. For #971 Change-Id: Ie635b58c835189fbf1523c71cf4b6bac5e8400e3 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/276493 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Suzy Mueller <suzmue@golang.org> Trust: Suzy Mueller <suzmue@golang.org> Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Change https://golang.org/cl/279727 mentions this issue: |
https://go-review.googlesource.com/c/vscode-go/+/276493 meant to add /usr/local/bin/go to the default path to search, but introduced a bug - we shouldn't return the path if the go binary doesn't exist. TODO: This function got complicated over time and deserves proper testing. For #971 Fixes #1065 Change-Id: I3ddf90983a1f66d6d76a3f9a50eb528a93904f3c Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/279727 Trust: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Change https://golang.org/cl/280592 mentions this issue: |
https://go-review.googlesource.com/c/vscode-go/+/276493 meant to add /usr/local/bin/go to the default path to search, but introduced a bug - we shouldn't return the path if the go binary doesn't exist. TODO: This function got complicated over time and deserves proper testing. For #971 Fixes #1065 Change-Id: I3ddf90983a1f66d6d76a3f9a50eb528a93904f3c Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/279727 Trust: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> (cherry picked from commit dd9c54f) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/280592 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Suzy Mueller <suzmue@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
I am running into this problem as well. Error on load: Commands on shell: go version echo $GOPATH code -v |
I also had the same problem. Installing the go in the default directory suggested in go docs (/usr/local/go) solved the problem for me. Probably the extension uses some hard typed path resolution 😢 . |
I had this issue and resolved by overriding goroot variable in VSC.
Good luck! |
Why is this using a hardcoded path? This is constantly erroring and the only current resolution was posted by @kroksys however this would need to be updated every time the version changes. Please open this issue back up and fix it as the terminal works properly it's just this plugin that has an issue. |
@gcstang: If you are encountering a problem, please open a new issue and fill out the issue template. Also, please see the Troubleshooting guide. |
Thanks so much @kroksys! I looked up the GOROOT variable with |
I'm using gvm to manage go version. Everytime I switch the go version, I have to modify vscode setting to avoid this problem. That's inconvenient. |
|
Thank you @gcstang |
It works for me with the config as below, so I don't have to update the config after each "go.alternateTools": {
"go": "/opt/homebrew/bin/go"
} |
The above worked for me (thank you @bittopaz), while the previous solution with "go.goroot" gave the following error: |
My VSCode was fine before, and today the problem just popped up. |
so am i |
Adding go.goroot to json file didn't work for me; "go.alternateTools": { |
For anyone for whom the above steps didn't work: check if you have the flatpak version of vs code/codium installed. It is a sandboxed environment, so it can't access your go tool suite. That's what happened to me, so i uninstalled the flatpak and installed the standard version following the instructions here, works like a charm :) |
Another solution is to always start VS Code with the |
Yeah, this is the one that worked best for me, I am using .asdf and it works for changing go version aswell. which go
/Users/simonreilly/.asdf/shims/go Then as above mark it in the settings: "go.alternateTools": {
"go": "/Users/simonreilly/.asdf/shims/go"
} |
On SteamDeck I used: conda install go and then in settings.json: "go.alternateTools": {
"go": "/home/deck/miniconda3/bin/go"
} … and it works even if flatpak avoid my PATH to be inherited. |
🤦🏻 |
I've been using I thought my env is right. This is my output from m2 mac:
Also set JSON config to: "go.gopath": "/Users/user/.local/share/rtx/installs/golang/1.20/go/bin",
"go.alternateTools": {
"go": "/Users/user/.local/share/rtx/installs/golang/1.20/go/bin"
} Reloading code and Restarting pc doesn't fix this too. |
And though, finally, I installed go with brew ( |
This is a better idea since we don't need to hard code GOROOT path, which might be change when we upgrade go version. |
On a Mac:
to not have to edit any settings etc |
Just like above, but you should open workspace settings, then there will be a {
"go.alternateTools": {
"go": "/home/jason/go/bin/go",
},
} |
For me it failed when I installed go using rtx. I saw antoher comment from someone who didn't manage to get it working with rtx, so just posting my solution (pretty much identical to asdf): {
"go.alternateTools": {
"go": "<home-path>/.local/share/rtx/shims/go",
}
} |
I cannot get anything listed above to work for me. Still cannot find GOROOT.
I'm out of ideas here... EDIT: Solution found, I had installed from the PopOS store an unofficial flatpak of VSCodium. I installed it from source, and no more issues. |
I restarted my MAC and this error appears every time I open it. |
Hi, if you want I have published the correct guide useful to use |
Thanks @TheUncleRemus . This is the solution I'm searching for and also frustrating me. But, I've decided to use GoLand instead. hahhhaa |
in my case the problem was the mise/asdf shims. To fix this I just run:
The shim symlink before and after: la /Users/user/.local/share/mise/shims/go
# before
/Users/user/.local/share/mise/shims/go -> /Users/user/.local/share/mise/shims/go
# after
/Users/user/.local/share/mise/shims/go -> /opt/homebrew/opt/mise/bin/mise |
manjaro users might attempt installing vscode and the go extension from AUR instead of via flatpak. This worked for me. |
After some testing, I found that if I configure the go path (GOROOT/PATH) in the .profile file and then log out of the computer or restart and reopen VSCode The reason might be that VSCode or this plugin does not seem to read the .bash_profile when accessing environment variables. The test results show that it retrieves environment variables through .profile on the user's login side. Config look like this: # in .profile
# ...
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin |
So what's the solution?
…On Sun, 11 Aug 2024, 7:10 am L8ng, ***@***.***> wrote:
After some testing, I found that if I configure the go path (GOROOT/PATH)
in the .profile file and then log out of the computer or restart and reopen
VSCode
The reason might be that VSCode or this plugin does not seem to read the
.bash_profile when accessing environment variables. The test results show
that it retrieves environment variables through .profile on the user's
login side.
Config look like this:
# in .profile# ...export GOROOT=$HOME/goexport PATH=$PATH:$GOROOT/bin
—
Reply to this email directly, view it on GitHub
<#971 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4COXE5IB33A5DDNWYGT3TZQ354PAVCNFSM4UFOFPNKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMRYGI3DGOBUGI3A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I found a solution for setup VSCode with Flatpak. It is quite simple. In my case I needed to change paths in the plugin settings {
"go.goroot": "/run/host/usr/local/go"
} Thats it! The reason for it is rather simple - Flatpak is a sandboxed environment but some paths are shared (or can be shared by adding extra flags) with host environment. In my case GO was installed to its standard path - |
For anyone using mise (formerly rtx) the solution is to point to wherever However, this will pin it to one specific version due to what seems like a bug (in my case
"go.alternateTools": {
"go": "~/.local/share/mise/installs/go/latest/go/bin/go"
}, |
I'm a Linux user. I followed your instructions and it works. This made my day. Thank you so much. |
So just to be sure, I enter "go env | grep GOROOT" in my terminal and copy that value into go.goroot into the vscode settings? |
remote link to ubuntu 22.04, and I finally got success through these steps: /usr/local ❯ ls go
api bin codereview.cfg CONTRIBUTING.md doc go.env lib LICENSE misc PATENTS pkg README.md SECURITY.md src test VERSION
/usr/local ❯ echo "export PATH=\$PATH:/usr/local/go/bin" >> /etc/profile
/usr/local ❯ source /etc/profile
/usr/local ❯ go version |
All of this is daft and still broken in 2024. My PATH is correct. I used brew to install VS Code. I used code -n to start vscode. GOENV_ROOT=$HOME/.p6/syndbg/goenv
GOENV_SHELL=zsh
GOROOT=$HOME/.p6/syndbg/goenv/versions/1.23.2
GOPATH=$HOME/go/1.23.2
$ go version; which go
go version go1.23.2 darwin/arm64
$HOME/.p6/syndbg/goenv/shims/go |
Specifically for using vscode on Windows, using Remote-SSH to connect to a RHEL9 VM. The solution for me was this: https://stackoverflow.com/a/62391678 I.e.: Press F1 or ctrl+shift+p and choose: |
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Gocode -v
orcode-insiders -v
to get version of VS Code or VS Code Insiderse5a624b788d92b8d34d1392e4c4d9789406efe8f
x64
go env
to get the go development environment detailsGOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ss/Library/Caches/go-build"
GOENV="/Users/ss/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/ss/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/ss/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.2/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
...
Share the Go related settings you have added/edited
None.
Describe the bug
Every time I restart vscode, it shows:
Failed to find the "go" binary in either。GOROOT() or PATH(/usr/bin:/bin:/usr/sbin:/sbin). Check PATH, or Install Go and reload the window.
It seems the PATH(
/usr/bin:/bin:/usr/sbin:/sbin
) from the message is not my actual path:And if I manually did
Developer: reload window
once after terminal started, it would work without errors.Steps to reproduce the behavior:
/usr/bin:/bin:/usr/sbin:/sbin
sleep 15
to~/.bash_profile
to make terminal very slow to upScreenshots or recordings
Refs may help:
The text was updated successfully, but these errors were encountered: