asdf-nodejs icon indicating copy to clipboard operation
asdf-nodejs copied to clipboard

How to update an alias version?

Open cabello opened this issue 3 years ago • 3 comments

Thank you for asdf-nodejs plugin, I've been using it for a few years now. Grateful for this free open source software. 🙇

Since https://github.com/asdf-vm/asdf-nodejs/pull/176 I changed my project to use lts-gallium instead of a hard-coded node version, recently I updated the project from version 16.13.1 to 16.14.0 and I could not figure it out how to update the definition of lts-gallium, this is what I ended up doing: uninstall followed by install.

❯ asdf uninstall nodejs lts-gallium
❯ asdf install nodejs
Installing alias lts-gallium as 16.14.0
nodejs 16.14.0 is already installed
Linking "lts-gallium" to "16.14.0"

Before attempting that I tried finding documentation on it and a few commands like asdf plugin update nodejs, and so on.

Is that the appropriate way to update node alias definitions?

cabello avatar Mar 14 '22 15:03 cabello

I'm having the same issue. Steps led to this issue:

  • Installed NodeJS 16.14.0
  • Installed NodeJS lts-gallium (lts-gallium was linked to 16.14.0)
  • Installed NodeJS 16.14.2
  • run asdf global nodejs lts-gallium
  • run asdf reshim
  • run node -v (still shows 16.14.0)

akkadaya avatar Mar 19 '22 07:03 akkadaya

Same question here. If someone can share here the proper way to update aliases (e.g., lts, lts-gallium, etc), I'd be happy to make a PR updating the docs.

According to #273, it looks like the best way right now is with asdf uninstall nodejs lts && asdf install nodejs lts. Is that correct?

crcastle avatar Apr 15 '22 19:04 crcastle

Yes, currently the easiest way of updating an lts alias is by uninstalling it and removing it. In the future, we might follow nvms approach of trying to fetch the latest lts version more frequently (maybe daily).

I will leave this issue open until the new cache invalidation is implemented.

augustobmoura avatar Apr 25 '22 18:04 augustobmoura

We changed the way aliases work on #348, now you need to explicitly opt-in with dynamic ranges on legacy version files (.tool-versions and .nvmrc). The .tool-versions file doesn't support non-deterministic versions, and supporting it on .tool-versions is not a feature we are seeking to implement at the moment.

To enable it, you need to provide an ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY environment variable choosing between the latest_available and latest_installed strategies, you can read more about it in the appropriate section on the README of the project. To make this choice permanent you can export said variable from your shell rc file like so:

export ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY=latest_installed
# OR
export ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY=latest_available

Please update the plugin by running asdf plugin-update nodejs. If a new issue arises with the new implementation please open a new issue.

augustobmoura avatar May 20 '23 16:05 augustobmoura