Skip to content

fix: don't use GOBIN env var if not defined - #3752

Open
carlosonunez wants to merge 1 commit into
fatih:masterfrom
carlosonunez:master
Open

fix: don't use GOBIN env var if not defined#3752
carlosonunez wants to merge 1 commit into
fatih:masterfrom
carlosonunez:master

Conversation

@carlosonunez

Copy link
Copy Markdown

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

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>
@carlosonunez

Copy link
Copy Markdown
Author

NOTE: This PR is meant to address #3753.

@bhcleek

bhcleek commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

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?

@carlosonunez

carlosonunez commented Aug 3, 2026 via email

Copy link
Copy Markdown
Author

@bhcleek

bhcleek commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

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?

@carlosonunez

carlosonunez commented Aug 3, 2026 via email

Copy link
Copy Markdown
Author

@carlosonunez

carlosonunez commented Aug 4, 2026

Copy link
Copy Markdown
Author

So I've confirmed that this was a PEBKAC. Sort of.

The golang plugin for asdf tells you to source (or have .bash_profile/.bashrc source) a script after installing it; see here. I thought that installing the plugin was all I needed to do to handle exports.

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 gopls detection issue brought forth by this issue.

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants