Skip to content

Failed to find the "go" binary with direnv #2617

@ciiqr

Description

@ciiqr

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.
    • go1.18.9 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • v0.11.0
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.74.3
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.38.0-dev
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • not possible (due to the nature of the bug)

Share the Go related settings you have added/edited

N/A

Describe the bug

When using the vscode-go extension along with an extension like direnv that updates the PATH, I get the error:
Failed to find the "go" binary in either GOROOT() or PATH(...)

After some brief debugging I determined the issue to be with getBinPathWithPreferredGopathGorootWithExplanation which uses the cached envPath instead of the most up to date PATH from process.env.

I tested with this function updated to pull the path every time and this has resolved the issue. Code I used in my fork here for reference: master...ciiqr:vscode-go:fix/direnv-support

Steps to reproduce the behavior:

  1. install go/direnv extensions
  2. added an .envrc to my project with the contents: PATH_add /path/to/go/bin (assuming go isn't already in your path)
  3. ran command: direnv: Reset and reload environment to update the path
  4. clicked Restart on the popup direnv produces to reload all extensions
  5. go extension pops up with the Failed to find the "go" binary... error (with /path/to/go/bin clearly not in the path it shows)

Screenshots or recordings

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeHelpWantedIssues that are not prioritized by the maintainers. Help is requested from community contributors.NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions