Skip to content

Fix latest-allowed ignoring exact version pins (bare, =, <=) - #546

Open
shuu01 wants to merge 1 commit into
tfutils:masterfrom
shuu01:fix/latest-allowed-exact-pin
Open

shuu01 wants to merge 1 commit into
tfutils:masterfrom
shuu01:fix/latest-allowed-exact-pin

Conversation

@shuu01

@shuu01 shuu01 commented Nov 20, 2026 •

Copy link
Copy Markdown

Problem

tfenv-resolve-version emits <version>:<regex>. For latest-style lookups (>, >=, ~>) this is latest:<regex>, which tfenv-version-name understands. For exact pins (bare "1.9.8", = "1.9.8", <= "1.9.8") it emits 1.9.8:^1.9.8$.

Previously tfenv-version-name only resolved latest-allowed inside its ^latest.*$ branch. The exact-pin result fell through to the "latest keyword alone" path, which forces the stable-version regex and replaces the resolved version with the newest stable release (e.g. 1.17.2 instead of 1.9.8).

Changes

  • Resolve latest-allowed before the ^latest.*$ check in lib/tfenv-version-name.sh.
  • If the resolved value is not latest:<regex>, strip :regex and use the exact version directly.
  • Add regression tests for bare, = and <= constraints via .terraform-version + TFENV_AUTO_INSTALL in test/test_use_latestallowed.sh.

Testing

  • ./test/run.sh test_use_latestallowed.sh — passed on macOS (darwin_arm64).
  • Based on v3.2.2 (de6ce2e).

Fixes #547.

Related: #394.

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.

latest-allowed ignores exact version pins and selects the newest stable version

1 participant