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

Legacy file strategy `latest_installed` selects wrong versions

Open luzat opened this issue 2 years ago • 0 comments

With .nvmrc containing v18 I get the following output:

$ export ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY=latest_installed
$ asdf list
  14.19.3
  18.16.0
  18.16.1
  18.2.0
 *18.9.0
  19.4.0

Expected behavior is to have 18.16.1 selected. The problem is, that resolve_legacy_version uses the order returned by a shell glob in list_installed_versions. A simple fix with GNU sort 7.0+ (released 2008) installed is to replace:

ASDF_NODEJS_SKIP_NODEBUILD_UPDATE=1 list_installed_versions nodejs

by:

ASDF_NODEJS_SKIP_NODEBUILD_UPDATE=1 list_installed_versions nodejs | sort -V

This does also work with at least FreeBSD's sort, but not macOS, but according to asdf docs coreutils are to be installed, so this should work, too.

luzat avatar Jul 18 '23 13:07 luzat