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

Resolving LTS version only outputs major number #369

Open
jabkoo opened this issue Oct 2, 2023 · 5 comments
Open

Resolving LTS version only outputs major number #369

jabkoo opened this issue Oct 2, 2023 · 5 comments

Comments

@jabkoo
Copy link

jabkoo commented Oct 2, 2023

Describe the Bug

When trying to resolve latest lts node version, I'm getting the result I was not expecting. When I run asdf nodejs resolve lts it only outputs a current major number 18 instead of a full version specified: 18.18.0. I get the same result when running asdf nodejs resolve lts --latest-available. Weirdly enough, running asdf nodejs resolve lts --latest-installed returns full version, so 18.18.0, even though I have no node versions installed yet (I am assuming it is using latest available version as a fallback?).

That is also causing asdf install nodejs lts not working, because it cannot resolve version 18.

Steps to Reproduce

Run:

  • asdf install nodejs lts
  • or asdf nodejs resolve lts
  • or asdf nodejs resolve lts --latest-available

Expected Behaviour

Command asdf nodejs resolve lts should output full semantic version of latest available LTS Node version and asdf install nodejs lts should be able to install it. As of 2023-10-02 it should output 18.18.0

Actual Behaviour

Only major version number is printed

> asdf nodejs resolve lts
18

This causes asdf install nodejs lts to fail. It needs full version specified with MAJOR.MINOR.PATCH

> asdf install nodejs lts 
Trying to update node-build... ok
node-build: definition not found: 18

Environment

OS:
Darwin jabko-macbook 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:52 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T8103 arm64

SHELL:
zsh 5.9 (x86_64-apple-darwin22.0)

BASH VERSION:
3.2.57(1)-release

ASDF VERSION:
v0.13.0

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/jabko/.asdf
ASDF_DIR=/opt/homebrew/opt/asdf/libexec
ASDF_CONFIG_FILE=/Users/jabko/.asdfrc

ASDF INSTALLED PLUGINS:
golang                       https://github.com/asdf-community/asdf-golang.git master e7e8171
hugo                         https://github.com/NeoHsu/asdf-hugo.git master 125ce37
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master 9275f49

asdf plugins affected (if relevant)

nodejs

@jabkoo
Copy link
Author

jabkoo commented Oct 3, 2023

Ok, I fixed that with adding ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY="latest_available" variable to my .zshrc, I guess that is how it is supposed to work?

However, it is really confusing, because I'm not using any legacy files like .node-version or .nvmrc. I just wanted to be able to resolve latest lts version from the command line with asdf nodejs resolve lts, so I wouldn't have guessed I need to set ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY variable just for that.

@augustobmoura Is this behaviour intended?

@Edditoria
Copy link

The README states "This option is only available for legacy version files". So, it does not work with .tools-version. IMHO it is a good decision.

  1. If your team uses ASDF (the ".tools-version"), just use the exact version stated in the .tools-version file.
  2. This is consistent with other plugins. Plus, unclear version sometimes create problems.
  3. If you team is more comfortable with partial version like "20" (not recommend) or "20.10" (better), use .nvmrc instead of .tools-version.

Most of my projects are using .nvmrc, and need to switch a lot. I use "latest_installed" to gain more control in my local env. It is smooth, so far.

@logicalup
Copy link

logicalup commented Feb 4, 2024

this is now happening with v20. It's a broken behavior imo. When trying to install latest lts version using the command that asdf says to use: "asdf install nodejs lts" it errors out node-build: definition not found: 20

I tried adding ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY="latest_available" and that didn't help

@brendanmatkin
Copy link

this is now happening with v20. It's a broken behavior imo. When trying to install latest lts version using the command that asdf says to use: "asdf install nodejs lts" it errors out node-build: definition not found: 20

I tried adding ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY="latest_available" and that didn't help

I agree, this is definitely broken behaviour, or incorrect docs (i.e. following the documentation leads to an error).
image

curbengh pushed a commit to curbengh/urlhaus-filter that referenced this issue Apr 7, 2024
consistent with gitlab/github CI
https://github.com/asdf-vm/asdf-nodejs#resolving-latest-available-lts-version-in-a-script

asdf version in cloudflare pages may not be the latest,
so does not always resolve 'lts' to the latest LTS

asdf currently is unable to install v20 through 'lts'
asdf-vm/asdf-nodejs#369 (comment)
@augustobmoura
Copy link
Member

Ok, I fixed that with adding ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY="latest_available" variable to my .zshrc, I guess that is how it is supposed to work?

However, it is really confusing, because I'm not using any legacy files like .node-version or .nvmrc. I just wanted to be able to resolve latest lts version from the command line with asdf nodejs resolve lts, so I wouldn't have guessed I need to set ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY variable just for that.

@augustobmoura Is this behaviour intended?

We could've the command fail if you don't provide either ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY or a flag forcing a strategy. The idea is that by default it should follow your strategy of preference, from the variable.

I will work on making failing when no variable is passed the default behavior

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

No branches or pull requests

5 participants