Skip to content

Fix asdf version detection for v0.17.0+ (fixes #59) #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

feltroidprime
Copy link
Contributor

@feltroidprime feltroidprime commented May 24, 2025

Fix asdf version detection for v0.17.0+ (fixes #59)

Problem

The get_asdf_version() function in starkup.sh uses a regex pattern with a $ anchor that expects the version number to be at the end of the line:

asdf --version 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+(-[^[:space:]]+)?$'

However, asdf v0.17.0 changed its output format to include additional information:

asdf version v0.17.0 (revision fc87e22)

The extra text (revision fc87e22) after the version number causes the regex to fail because of the $ end-of-line anchor, resulting in an empty string instead of extracting 0.17.0.

Root Cause Analysis

  1. Regex failure: The $ anchor expects version to be at end of line, but asdf v0.17.0+ includes revision info
  2. Empty version extraction: get_asdf_version() returns empty string instead of 0.17.0
  3. Incorrect legacy detection: is_asdf_legacy() calls version_less_than("", "0.16.0")
  4. Version comparison bug: Empty string is treated as less than 0.16.0, so function returns true
  5. Wrong command usage: Script incorrectly treats asdf v0.17.0 as legacy
  6. Command failure: Uses deprecated asdf global instead of modern asdf set --home
  7. Error: asdf global doesn't exist in v0.17.0, causing installation failure

Solution

Simple fix: Remove the $ anchor from the regex pattern to allow matching versions with additional text after them.

Before

asdf --version 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+(-[^[:space:]]+)?$'

After

asdf --version 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+(-[^[:space:]]+)?'

Testing

Verified the fix works correctly with various asdf version output formats:

Input Expected Result Status
asdf version v0.17.0 (revision fc87e22) 0.17.0 0.17.0
v0.16.7 0.16.7 0.16.7
0.15.9 0.15.9 0.15.9
asdf v0.17.1-beta 0.17.1-beta 0.17.1-beta
version 0.14.0 0.14.0 0.14.0

Legacy Detection Test

Confirmed is_asdf_legacy() now works correctly:

asdf Version Expected Detection Result Status
asdf version v0.17.0 (revision fc87e22) modern modern
v0.16.0 modern modern
0.15.9 legacy legacy
0.14.0 legacy legacy

Impact

  • Fixes issue BUG : Incorrect asdf version detection #59: asdf v0.17.0+ now correctly detected as modern
  • Maintains backward compatibility: Works with older asdf versions
  • Uses correct commands: asdf set --home for modern, asdf global for legacy
  • No breaking changes: Only fixes the version detection logic

Files Changed

  • starkup.sh: Line 434 - Updated regex in get_asdf_version() function

Related Issues

Closes #59

Verification Steps

To verify this fix works:

  1. Install asdf v0.17.0+
  2. Run starkup installation
  3. Confirm it uses asdf set --home instead of asdf global
  4. Installation should complete successfully

@feltroidprime feltroidprime requested a review from a team as a code owner May 24, 2025 09:37
Copy link
Contributor

@maciektr maciektr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! ❤️

@DelevoXDG DelevoXDG merged commit 272ec82 into software-mansion:main May 27, 2025
28 of 42 checks passed
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.

BUG : Incorrect asdf version detection
3 participants