Skip to content
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

fix: change version resolution order to restore legacy file fallback behavior #1956

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nek023
Copy link

@nek023 nek023 commented Feb 14, 2025

Summary

Fixed the issue where the order of processing during version resolution was reversed between v0.15 and v0.16.

In v0.15, the lookup was performed in the order of .tool-versions → legacy file.

asdf/lib/utils.bash

Lines 166 to 182 in 31e8c93

file_name=$(asdf_tool_versions_filename)
asdf_version=$(parse_asdf_version_file "$search_path/$file_name" "$plugin_name")
if [ -n "$asdf_version" ]; then
printf "%s\n" "$asdf_version|$search_path/$file_name"
return 0
fi
for filename in $legacy_filenames; do
local legacy_version
legacy_version=$(parse_legacy_version_file "$search_path/$filename" "$plugin_name")
if [ -n "$legacy_version" ]; then
printf "%s\n" "$legacy_version|$search_path/$filename"
return 0
fi
done

In v0.16, the lookup order was changed to legacy file → .tool-versions.

legacyFiles, err := conf.LegacyVersionFile()
if err != nil {
return versions, found, err
}
if legacyFiles {
versions, found, err := findVersionsInLegacyFile(plugin, directory)
if found || err != nil {
return versions, found, err
}
}
filepath := path.Join(directory, conf.DefaultToolVersionsFilename)
if _, err = os.Stat(filepath); err == nil {
versions, found, err := toolversions.FindToolVersions(filepath, plugin.Name)
if found || err != nil {
return ToolVersions{Versions: versions, Source: conf.DefaultToolVersionsFilename, Directory: directory}, found, err
}
}

The documentation states that setting legacy_version_file = yes enables the behavior: "Use plugin fallback to legacy version files if available."
To ensure fallback works as expected, the lookup order needs to be reverted to the v0.15 behavior.

https://asdf-vm.com/manage/configuration.html#legacy-version-file

Other Information

@nek023 nek023 marked this pull request as ready for review February 14, 2025 16:17
@nek023 nek023 requested a review from a team as a code owner February 14, 2025 16:17
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