Skip to content

Fix major.minor version resolution in shims when using go.mod#499

Closed
ChronosMasterOfAllTime with Copilot wants to merge 5 commits into
masterfrom
copilot/fix-go-shims-resolution
Closed

Fix major.minor version resolution in shims when using go.mod#499
ChronosMasterOfAllTime with Copilot wants to merge 5 commits into
masterfrom
copilot/fix-go-shims-resolution

Conversation

Copilot AI commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

When GOENV_GOMOD_VERSION_ENABLE=1 is set and go.mod specifies a major.minor version (e.g., go 1.25), shim execution fails with "command not found" even when the corresponding patch version (e.g., 1.25.4) is installed.

# go.mod contains: go 1.25
# version 1.25.4 is installed

goenv exec go  # Fails: goenv: 'go' command not found

Root cause: goenv-version-name resolved "1.25" → "1.25.4" internally but never returned the resolved version, leaving shims with no version to execute.

Changes

libexec/goenv-version-name

  • Add resolved version to output array when GOENV_GOMOD_VERSION_ENABLE is set
  • Previously discarded the resolved version after successful version_exists check

libexec/goenv-which

  • Pre-resolve major.minor versions before searching for executables
  • Align version_exists implementation with goenv-version-name (handle both major.minor and major.minor.patch)
  • Standardize on GOENV_GOMOD_VERSION_ENABLE variable (was inconsistently using GOENV_GO_MOD_ENABLE)

Tests

  • Cover major.minor resolution from go.mod and direct GOENV_VERSION
  • Cover shim execution path via goenv-exec
  • Verify full versions (1.25.3) aren't re-resolved to latest patch
Original prompt

This section details on the original issue you should resolve

<issue_title>Issue with major.minor shims not resolving correctly</issue_title>
<issue_description>After running

# GOENV_GO_MOD_ENABLE and GOENV_AUTO_INSTALL are both enabled here
goenv 
eval "$(goenv init -)"

Using latest patch version 1.25.4
Downloading go1.25.4.linux-amd64.tar.gz...
-> go1.25.4.linux-amd64.tar.gz
Installing Go Linux 64bit 1.25.4...
Installed Go Linux 64bit 1.25.4 to /root/.goenv/versions/1.25.4

# we experience a failure here
/root/.goenv/shims/go 
goenv: 'go' command not found 

The 'go' command exists in these Go versions:
  1.20.14
  1.21.13
  1.22.12
  1.23.12
  1.24.8
  1.25.4

We need to address this. Basically my go mod has go defined as go 1.25.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits December 1, 2025 21:02
Co-authored-by: ChronosMasterOfAllTime <28963807+ChronosMasterOfAllTime@users.noreply.github.com>
Co-authored-by: ChronosMasterOfAllTime <28963807+ChronosMasterOfAllTime@users.noreply.github.com>
… goenv-version-name

Co-authored-by: ChronosMasterOfAllTime <28963807+ChronosMasterOfAllTime@users.noreply.github.com>
Co-authored-by: ChronosMasterOfAllTime <28963807+ChronosMasterOfAllTime@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with major.minor shims not resolving correctly Fix major.minor version resolution in shims when using go.mod Dec 1, 2025
@github-actions github-actions Bot added the bug label Dec 1, 2025
@ChronosMasterOfAllTime ChronosMasterOfAllTime deleted the copilot/fix-go-shims-resolution branch December 1, 2025 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with major.minor shims not resolving correctly

2 participants