Skip to content

fix: restore symlink support for tool versions #1937

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

khmm12
Copy link

@khmm12 khmm12 commented Feb 10, 2025

Summary

Fixes a regression where symlink support for tool versions was inadvertently dropped. Versions prior to 0.16.0 supported symlinks for tool versions, which are used, for example, by alias plugin.

@khmm12 khmm12 requested a review from a team as a code owner February 10, 2025 13:27
originPath := InstallPath(conf, plugin, toolversions.Version{Type: "version", Value: versionStr})
aliasPath := InstallPath(conf, plugin, toolversions.Version{Type: "version", Value: aliasStr})
err := os.Symlink(originPath, aliasPath)
assert.Nil(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

These last two lines can be combined into one.

t.Run("returns installed versions including symlinks", func(t *testing.T) {
conf, plugin := generateConfig(t)
mockInstall(t, conf, plugin, "1.0.0")
aliasVersion(t, conf, plugin, "1.0.0", "latest")
Copy link
Member

Choose a reason for hiding this comment

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

We do not support aliases in asdf core. Please rename this function to something that indicates it only generates a symlink, and please remove the latest version as latest is never permitted in .tool-versions files.

Copy link
Member

@Stratus3D Stratus3D left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @khmm12! I'm in favor of restoring symlink support for .tool-versions files if it is indeed missing, but it does not appear that these changes actually do that. These changes are affecting how asdf determines if a version is installed, which is completely unrelated to the process that locates and reads .tool-versions files. I think it'd be best to close this PR as I don't think any of these changes can be accepted.

@khmm12
Copy link
Author

khmm12 commented Feb 12, 2025

Greetings @Stratus3D 👋

These changes are affecting how asdf determines if a version is installed, which is completely unrelated to the process that locates and reads .tool-versions files

Exactly. The previous Bash-based versions correctly detected installed tool versions that were symlinks. However, the current implementation no longer recognizes them, which is a clear regression.

It seems there might be some misunderstanding—this is not about .tool-versions files themselves, but about tool versions and their symlinks. The issue is that symlinked versions, which were previously supported, are no longer detected.

I agree that aliasing should be handled by reworking how asdf selects tool versions from .tool-versions files. However, this PR specifically addresses the regression where symlinked versions, which users actively rely on, stopped working.

Example use case of symlinks:

asdf/installs/nodejs/22.10.0
asdf/installs/nodejs/22.10      -> ./22.10.
asdf/installs/nodejs/22         -> ./22

.tool-versions

nodejs 22

This setup worked in previous versions but is no longer working. Since users depend on this behavior, it seems reasonable to restore it.

Could you clarify do you see an alternative way to address the issue?

Fixes a regression where symlink support for tool versions was inadvertently dropped.

Fixes asdf-vm#1873
@khmm12 khmm12 force-pushed the fix/backward-compatibility-for-tool-version-symlinks branch from 9bb6ad8 to 28e6b1c Compare February 12, 2025 10:34
@yacchi
Copy link
Contributor

yacchi commented Feb 18, 2025

My plugin (asdf-go-sdk) has also stopped working due to this issue. However, I have confirmed that this pull request resolves the problem.

From what I can see, symbolic link detection is handled carefully, and the errors module is used for error handling, making it a well-implemented fix that properly restores the previous behavior.

I hope this gets merged and released soon so that my plugin can function again.

@Stratus3D
Copy link
Member

Hi @khmm12. The asdf data directory (~/.asdf/ by default) is where asdf is allowed to store plugins, versions, shims, and anything else it needs to store on disk on the computer. It's very important that these directories are not tampered with. The only directories in ~/.asdf that plugins should ever write to are those given to the plugin's callbacks in the *_PATH environment variables - ASDF_INSTALL_PATH, ASDF_DOWNLOAD_PATH, and ASDF_PLUGIN_PATH. The only other place plugins should read/write files is in an OS-provided temp directory.

I'm sorry @yacchi you'll need to alter your plugin so that it doesn't need to write symlinks.

@Stratus3D Stratus3D closed this Feb 18, 2025
@yacchi
Copy link
Contributor

yacchi commented Feb 19, 2025

@Stratus3D

Thank you for your response.

I understand the importance of asdf's data directory structure and the need to limit where plugins read and write files. However, the asdf-go-sdk plugin follows the behavior of the Go language itself by utilizing the default installation directory ($HOME/sdk).
This approach ensures compatibility with various tools and IDEs that expect the Go SDK to be in this location.

Changing this directory would break compatibility with these tools, making the development experience more cumbersome. Symbolic links were a solution to bridge this compatibility gap while integrating with asdf.

Given the current restrictions, do you have any suggestions or guidance on how to maintain compatibility with IDEs while adhering to asdf's data directory policy? We would greatly appreciate any ideas or best practices for addressing this challenge.

Thank you for your support and consideration.

@ofalvai
Copy link

ofalvai commented Feb 19, 2025

@Stratus3D I'd like to echo the concerns of @khmm12 and @yacchi about the current situation. There has been a lot of feedback over the years in #523 that alias versions as a concept is useful. I understand why you don't want it to become a core feature of asdf itself, but I'd like you to consider the practical reality of how asdf is used by many of its current users (plus the people who switched to Mise because of missing features like this one). The asdf-alias plugin was born to fill this gap, and while I agree that it's an imperfect solution, it is a practical fix for the current situation where the version alias concept is not a core feature of asdf itself.

Thank you for considering our use case, and I really hope we can find a way forward that fits everyone.

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.

regresssion / feature: [0.16.0] asdf no longer recognizes symlinks as versions
4 participants