asdf icon indicating copy to clipboard operation
asdf copied to clipboard

Allow user to get latest lts version without installing it and allow updating local version without installing it

Open onnimonni opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe

Given that I run following sequence of commands

$ asdf plugin install nodejs
$ asdf install nodejs lts
$ asdf global nodejs lts
$ asdf latest nodejs lts
lts
$ node --version
v18.14.1

It would be great that asdf latest nodejs lts would not output lts but it would actually output the version behind the keyword.

This would help to build automation when we don't yet have dependabot integration with asdf.

One could just check what asdf latest nodejs lts would output and create a new pull request with that value 👍

Describe the proposed solution

If I would install nodejs plugin and ask for latest lts I would want to see the actual version instead of the lts string:

$ asdf plugin install nodejs
$ asdf latest nodejs lts
18.14.1

Simiarly it would be great that one could override the local command to update the local version even if it's not installed:

$ asdf local nodejs 18.14.1
version 18.14.1 is not installed for nodejs

So eg using --force flag the command above would still succeed:

$ asdf local nodejs 18.14.1 --force

Describe similar asdf features and why they are not sufficient

The workaround described below will achieve the same thing but it's slow and needlessly installing software that wasn't needed in the CI. I will be doing this for multiple projects everyday and I wouldn't want to waste these resources unless it's the only way 😢.

Describe other workarounds you've considered

The closed issue #1024 did contain a workaround but it requires installing the nodejs version and is making the github action slower and needlessly wasting resources.

By adding this simple command we would allow scheduled CI actions to skip actually installing the nodejs and just getting the new value instead

# Use `awk` to split the returned line by white-space and take the 2nd column:
$ asdf current nodejs | awk '{print $2}'

lts


# Resolve the `current` nodejs version:
$ readlink -f $(asdf where nodejs $(asdf current nodejs | awk '{print $2}' )) | awk -F '/' '{print $(NF)}'

16.17.0


# Set the explicitly resolved version locally:
$ asdf local nodejs $(readlink -f $(asdf where nodejs $(asdf current nodejs | awk '{print $2}' )) | awk -F '/' '{print $(NF)}')

onnimonni avatar Feb 19 '23 17:02 onnimonni

Because aliases are not a first-class concept inside of asdf, I don't believe this is possible. asdf has no way to tell what version is or is not an alias. I've proposed adding this concept to asdf on this ticket, however I know the asdf team has historically been against making aliases first-class functionality.

jdx avatar Mar 19 '23 19:03 jdx