Skip to content

gopls and Go tools not available after switching Go versions #533

Description

@lpppy

Problem

When switching Go versions via goenv install / goenv local / goenv global, previously installed Go tools (e.g. gopls, dlv, staticcheck) are no longer available because each Go version has its own $GOPATH/bin. This causes IDE features (code navigation, auto-completion, diagnostics) to silently break.

Steps to Reproduce

  1. Install Go 1.23 via goenv, install gopls: go install golang.org/x/tools/gopls@latest
  2. Switch to Go 1.24: goenv local 1.24.10
  3. Run gopls version → fails or picks up a stale shim

Expected Behavior

After switching Go versions, either:

  • Go tools installed in the previous version should still be accessible, OR
  • goenv should warn the user that tools need to be reinstalled, OR
  • goenv should provide a mechanism (e.g. goenv rehash --install-tools) to automatically reinstall a configured set of tools for the new version

Suggested Solutions (any of these would help)

  1. Post-switch hook: Allow users to define a list of tools in a config file (e.g. ~/.goenv/default-tools) that get auto-installed after version switch, similar to how nodenv has default-packages.
  2. Warning on shim miss: When a shim is invoked but the underlying binary doesn't exist for the current Go version, print a helpful error message suggesting go install ... instead of a generic "not found".
  3. Shared tools directory: Optionally allow tools to be installed to a version-independent path so they survive version switches.

Environment

  • goenv 2.2.23
  • macOS (darwin/arm64)
  • Shell: zsh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions