Skip to content

fix(shims): rehash scans both v3 and legacy gopath bin (Option C — additive, #545)#548

Open
jlec wants to merge 1 commit into
go-nv:mainfrom
jlec:fix/shims-scan-both
Open

fix(shims): rehash scans both v3 and legacy gopath bin (Option C — additive, #545)#548
jlec wants to merge 1 commit into
go-nv:mainfrom
jlec:fix/shims-scan-both

Conversation

@jlec
Copy link
Copy Markdown
Contributor

@jlec jlec commented May 29, 2026

Summary

Option C of three for issue #545.

Strictly additive fix: resolver and rehash now consult both $GOENV_ROOT/versions/$version/gopath/bin and $HOME/go/$version/bin. Tools installed under either layout become shims. No behaviour is removed, no migration is needed.

Changes

  • internal/config/config.go — adds LegacyHomeGopathBin(version) returning $HOME/go/$version/bin (empty string on os.UserHomeDir() error).
  • internal/resolver/resolver.go:
    • ResolveBinary checks LegacyHomeGopathBin after VersionGopathBin (when GOPATH is enabled).
    • GetBinaryDirectories includes the legacy path.
    • FindVersionsWithBinary includes the legacy path.
  • internal/resolver/resolver_test.go (new) — 5 tests covering the new behaviour and the GOPATH-disabled negative case.

Trade-offs

  • Pro: zero migration. Works for v2-installed users immediately. Works for v3-native installs immediately. Smallest meaningful fix.
  • Con: maintains two paths in perpetuity. If the same tool name exists in both directories, first-hit wins (deterministic ordering: v3 dir then legacy).

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... — all packages pass, including 5 new resolver tests
  • Manual smoke test: goenv rehash against an environment with 32 tools in ~/go/$ver/bin produces 38 shims (same as v2 master).

🤖 Generated with Claude Code

…ditive)

Strictly additive fix: resolver and rehash now consult both
$GOENV_ROOT/versions/$ver/gopath/bin and $HOME/go/$ver/bin so that
tools installed by either layout appear as shims.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant