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: asdf latest --all report wrong runtimes (#1180) #1191
Conversation
Thanks for the PR and sorry for the late review here @roele. Would implementing the correct logic in a plugin's |
@Stratus3D Unfortunately I'm not familiar with this callback. As far as i have seen none of the plugins implement |
@Stratus3D Your proposal would break I think the solution here is the most appropriate.
|
@@ -0,0 +1,6 @@ | |||
#!/usr/bin/env bash | |||
|
|||
versions_list=(acme-1.0.0 acme-1.1.0 distro-2.0.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also test this codepath for versions which have
- multiple prefix parts, EG:
zulu-jre-musl-8.42.0.23
- suffixes after the semver version
- where list-all returns non-prefixed/suffixed versions.
asdf python
shows examples of all these types:
...
3.10.5
3.11.0b4
3.11-dev
3.12-dev
activepython-2.7.14
activepython-3.5.4
activepython-3.6.0
anaconda-1.4.0
anaconda-1.5.0
...
pypy3.6-7.3.3
pypy3.7-c-jit-latest
pypy3.7-7.3.2-src
...
pypy3.9-7.3.8
pypy3.9-7.3.9-src
pypy3.9-7.3.9
pyston-2.2
pyston-2.3
pyston-2.3.1
pyston-2.3.2
pyston-2.3.3
pyston-2.3.4
stackless-dev
stackless-2.7-dev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pypy3.9-7.3.8
pypy3.9-7.3.9-src
IMO these are two different variants, though most querying added to commands are prefix-only queries, so I guess these should be resolved as a single variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, current implemenation does not yet handle suffixes. But i agree that this example should be treatet as a single variant. I would consider suffixes after the sematic version not as a variant but rather a special version like beta, GA, src or similar.
lib/functions/versions.bash
Outdated
for variant in $installed_variants; do | ||
local version | ||
version=$(list_all_command "$plugin_name" "$(echo "$variant" | tr -d '[:space:]')" | | ||
grep -ivE "(^Available version:|-src|-dev|-latest|-stm|[-\\.]rc|-alpha|-beta|[-\\.]pre|-next|(a|b|c)[0-9]+|snapshot|master)" | | ||
# filter for exact match or with version suffix to deal with overlaps (e.g. zulu-18.28.13, zulu-jre-18.28.13) | ||
grep -iE "^($variant|$variant(-\d+.*)?)\$" | | ||
sed 's/^[[:space:]]\+//' | | ||
tail -1) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While shorter to write this way, we're calling list_all_command
for each variant when really it only needs to be called once for the plugin. The list_all_command
executes <plugin>/bin/list-all
which performs a network call and file read/writes. It is usually a really slow command. Can you rework this so list_all_command
is called once per plugin and not variant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very valid concern, will rework this part 👍
sed -e "s/\(^.*\)\-[0-9].*/\1/" | # extract variant prefix | ||
sort -u | # unique | ||
sed -e "s/^[[:space:]]*[0-9].*//" | # remove versions without variant prefix | ||
sed '/^[[:space:]]*$/d') # remove empty lines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm uncomfortable with this being part of asdf. I know we have similar logic that already exists in a few places, but this doesn't feel like a future-proof solution. We're effectively using versions to store more than the version number. Versions are a combination of tool type (e.g. openjdk) and version (e.g. 1.2.3). I know this is a pretty fundamental change, but I think we might be better off either introducing a type field in addition to version, or specifying that plugins only support one type of thing (e.g. instead of a java plugin we have an openjdk plugin). Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specifying that plugins only support one type of thing
interesting proposal. I know this would also upset the Hashicorp plugin which manages the binaries for the Hashi ecosystem and not just different sources of the same runtime. I feel like Java and Hashicorp plugins are different enough and both valid in the spec we have defined 🤔
As I stated earlier
After further thought, I think the most beneficial thing to do is remove this
The Issues discussing the desire for the command and the current obtuse behaviour have a total of 3 participants (outside asdf core team) and seemingly no support for this behaviour (use Issue/PR GitHub emojis as the metric). I propose we remove it. @Stratus3D Do you have any strong feelings either way? @roele I'm sure hearing this is unpleasant given your input on this PR was significant. I am sorry. Are there points I am missing which might convince me otherwise? |
@jthegedus Even though i would love the convenience of a single command telling me what packages are outdated, I am fine with that decision and understand that maintainability has upmost priority. |
I agree on the convenience. Perhaps this is a good candidate for a one-line shell cmd to demonstrate in a cookbook/recipes section in the docs. Until the points raised above by @Stratus3D are addressed I don't think this passes any cost/benefit analysis. I will close this PR. I will raise a PR to back out the Thanks for your contributions here and I hope you contribute again 🙏 |
Summary
Revisites the logic for command
latest --all
which returns wrong version numbers if the plugin uses multiple distros/variants (e.g. Java, Python, Ruby, ...).Instead of falling back to use the latest available version (
tail -1
) from all the available versions vialist all
, the code tries to list specific versions for installed distros. This is done by getting a distinct list of installed distros assuming the format - and then getting the latest version for that specific distro via additional version query. If a plugin has no installed versions, the old behaviour showing the latest from all available versions is used.Additionally if multiple distros are installed (e.g. Java; opendjdk, zulu) the output lists each installed one with its latest version and status.
Fixes: #1180
Other Information