fix: don't use GOBIN env var if not defined - #3752
Conversation
This commit works around an issue I encountered wherein `gopls` fails to load despite `:GoInstallBinaries` downloading and installing it. This happened because I was using `asdf` to manage my Go version and `asdf` does not set `$GOBIN` in the environment by default. All that's being done here is getting `g:go_bin` to `$GOBIN` if its defined in the environment (usually the case when you install `go` with Homebrew or something like that) and sets it to the output of `go env GOBIN` otherwise. Signed-off-by: Carlos Nunez <13461447+carlosonunez@users.noreply.github.com>
|
NOTE: This PR is meant to address #3753. |
|
This seems to be doing the opposite of what the description says: it's preferring |
|
Yes; this preserves existing behavior (use GOBIN if "go env gobin" is set). The fix here is to use output from "go env gobin" if $GOBIN is empty.On Aug 3, 2026, at 14:37, Billie Cleek ***@***.***> wrote:bhcleek left a comment (fatih/vim-go#3752)
This seems to be doing the opposite of what the description says: it's preferring $GOBIN regardless of what go env gobin returns. Is that your intent?
—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
|
Vim-go already uses |
|
I use asdf to manage Golang versions. asdf doesn't export it when the golang version is reshimmed, or at least it doesn't in my setup.In this case, the .tool-versions file in my $HOME links to Go 1.26, but I was working with a project whose .tool-versions file requests Go 1.21."cd"ing into the project's directory triggers the asdf reshim to 1.21 as expected, but "echo $GOBIN" returns nothing.On Aug 3, 2026, at 16:02, Billie Cleek ***@***.***> wrote:bhcleek left a comment (fatih/vim-go#3752)
Vim-go already uses go env GOBIN and go env GOBIN gets its value from $GOBIN. How are you getting into some state where go env GOBIN returns something different than $GOBIN?
—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
|
So I've confirmed that this was a PEBKAC. Sort of. The However, assuming that the aforementioned script is not sourced, you'll get output that looks like this: $: echo "GOBIN in env: '$GOBIN'"
GOBIN in env: ''
$: echo "GOBIN from go env: '$(go env GOBIN)'"
GOBIN from go env: '/Users/cn/.asdf/installs/golang/1.26.5/bin'Which causes the @bhcleek: It's your team's call on whether y'all this PR should get merged in. Consider this documentation for future readers (or their agents) otherwise. |
This commit works around an issue I encountered wherein
goplsfails toload despite
:GoInstallBinariesdownloading and installing it. Thishappened because I was using
asdfto manage my Go version andasdfdoes not set
$GOBINin the environment by default.All that's being done here is getting
g:go_binto$GOBINif itsdefined in the environment (usually the case when you install
gowithHomebrew or something like that) and sets it to the output of
go env GOBINotherwise.Signed-off-by: Carlos Nunez 13461447+carlosonunez@users.noreply.github.com