Skip to content

feat: add version validation when using set command #2070

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jrodriigues
Copy link

Summary

These changes add version validation when using asdf set <plugin> <version> to ensure that only available versions for the plugin are added.
If the version is not part of the available list, the program will fail with a descriptive error message:

❯ ./asdf set ruby 3.9.0
version 3.9.0 is not available for plugin ruby

Fixes: #1983

Other Information

I refactored some existing code from the list command into a new function on the set package since the objective on both commands is the same.

@jrodriigues
Copy link
Author

I believe that the new function to retrieve a plugin's available versions makes sense to be a plugin method rather than a standalone function in the set package, so I pushed a change for it.

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 @jrodriigues ! I think this is nice improvement. I think introducing that GetAvailableVersions method was a good idea.

I'd like to merge this but I see it's failing linter and test checks. Can you take a look and fix them?

@jrodriigues jrodriigues force-pushed the master branch 2 times, most recently from c78cb97 to 2e1c14c Compare May 25, 2025 15:27
These changes ensure that the specified version is available for the
plugin.
Fixes asdf-vm#1983
@jrodriigues
Copy link
Author

jrodriigues commented May 25, 2025

I have fixed the lint check, but I believe there is something wrong with the test workflow setup.
It's failing because it can't find the list-all callback for the lua plugin (used in the test script), however all tests pass locally (on macOS with lua plugin installed, and list-all callback correctly setup in $HOME/.asdf/plugins/lua/bin/list-all).

I added the error description to the output for debugging, and I believe the error is happening on this line.
Are you able to confirm this somehow?

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: plugin version setting validation
2 participants