Commit Graph
764 Commits
Author SHA1 Message Date
Hridhin Varkey JosephandJordan Harband f22f8cc1a4 [Perf] nvm_version: resolve an exact version that is not installed without nvm_ls
When `default` points to an exact version that is not installed,
every shell start listed all installed versions twice just to print `N/A`.

Co-authored-by: Hridhin Varkey Joseph <318277129+hridhinvarkeyjoseph@users.noreply.github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-12-04 14:39:25 -08:00
Amiraslan MuradovandJordan Harband 9ac2cbb95f [Fix] Ignore a UTF-8 BOM in default-packages
Co-authored-by: Amiraslan Muradov <70092128+aslanmuradov@users.noreply.github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-12-04 13:08:03 -08:00
NUAAwqyandJordan Harband 0f3a2589db [Fix] nvm_process_nvmrc: strip a UTF-8 BOM from .nvmrc
Some editors save a UTF-8 file with a byte order mark (`EF BB BF`) at the start.
nvm read those bytes as part of the first line,
so an otherwise valid `.nvmrc` made `nvm use`, `nvm install`, and `nvm_auto` fail to resolve the version.

The `nvmrc` validator trims each line with JavaScript's `trim()`, which removes a BOM,
so the same file is valid there and was misread by nvm.
Remove the mark at the start of the content before comments and whitespace are processed.

Signed-off-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-authored-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-12-04 11:46:36 -08:00
Jordan Harband 896380e754 [Fix] nvm_npm_global_modules: don't turn blank lines into a - package
deaffdb1 prefixed every line of `npm ls` output, including the blank line older npm prints last,
so `--reinstall-packages-from` installed the npm package named `-`.
2026-12-04 11:40:02 -08:00
Jordan Harband deaffdb1f1 [Fix] nvm_npm_global_modules: keep npm's tree drawing out of shell variables
On arm64, dash 0.5.13.5 (Alpine 3.25) corrupts some non-ASCII bytes it stores in a variable,
so no package was parsed out of `npm ls` and `--reinstall-packages-from` passed it junk.
2026-12-04 10:36:29 -08:00
Srinivas Chippagiri 2404c007fb [Docs] nvm --help: list nvm use --delete-prefix
Completion offers what the help lists, so it offers the flag too.

Fixes #4013
2026-11-29 20:39:32 -08:00
Peter Dave Hello 43a65b3ac5 [Fix] nvm install --offline: try cached versions meeting the minimum
A matching installed version can be below `--min` or `NVM_MIN`
even when a usable cached archive satisfies the request.
Returning that version before checking the cache makes an otherwise viable offline install fail.

Prefer an installed version only when it meets the minimum.
Otherwise, take the newest cached version that meets it and can be installed,
resolving aliases and respecting `-b`, `-s`, and platform restrictions.
When none qualifies, keep the installed or newest cached match,
so the existing diagnostics still explain the failure.
Without a minimum, resolution is unchanged
2026-12-03 00:59:03 -08:00
Peter Dave Hello a549731187 [Fix] install.sh: propagate requested Node.js installation failures
Automated provisioning with NODE_VERSION can continue without the requested Node.js version when the installer discards a failure from `nvm install`.
Re-resolving a successful install's selector locally can also misreport its result for `stable` and `--lts`.

Use the install command's status and preserve it through cleanup and setup guidance.
Cover failure and success paths in isolated Bash processes,
including errexit,
without allowing shell tracing to satisfy assertions on installer output.
2026-12-02 15:22:57 -08:00
Jordan Harband 2d393cbc36 [Fix] nvm uninstall: remove aliases once a partial deletion takes the binary
When the version directory can't be fully removed but its binary was,
the version is no longer installed,
so retrying `nvm uninstall` reports it as not installed and never reaches the alias cleanup.
Remove its aliases anyway, and still report the failure.
2026-12-02 14:35:48 -08:00
Peter Dave Hello d6297b5a15 [Fix] nvm uninstall: report version directory removal failures
The permission preflight cannot guarantee that recursive deletion will succeed.
Ignoring the removal status can report success and delete aliases even when the installed version was not fully removed.
It also prevents commands such as `nvm prune` from counting failures accurately.

Keep cache cleanup best-effort,
but check version-directory removal before reporting success or deleting aliases.
Preserve the native rm diagnostic and report the directory path to aid recovery from partial removal.

Exercise real permission failures and a cache-only failure independently of download slug naming.
Use portable sourcing parameters, check fixture setup,
isolate diagnostics,
and preserve failure status during cleanup.

Refs #1641, #1732
2026-12-02 00:20:35 -08:00
Peter Dave Hello 2f736f5781 [Fix] install.sh: abort when adding the required Git remote fails
An existing installation may need a new remote before it can fetch an update.
If adding that remote fails,
the helper returns 2 but the installer ignores it,
modifies the profile,
and can report success while still using the old version.

Exit at the failing command, consistent with other fatal Git errors.

Use a real Git config lock to exercise both installation methods.
Verify that the test reaches its intended failure rather than passing on an unrelated nonzero exit.

Regression introduced by dbda4b9387
2026-12-01 03:57:04 -08:00
Peter Dave Hello 6c74a83e52 [Fix] Respect Linux CPU affinity when selecting make jobs
Use the optional nproc utility to count processors available to the current process rather than counting all processors exposed in `/proc/cpuinfo`.
Ignore OpenMP-specific overrides and fall back to the existing Linux probe when nproc is absent,
fails, or returns an invalid count.

Retain the existing job-count policy, explicit -j overrides,
and other OS probes.
Cover restricted CPU counts, fallback paths,
and inherited OpenMP settings using isolated probe shims.
2026-11-26 03:13:20 +08:00
IainandJordan Harband 94887140eb [Fix] nvm current, nvm which system: find node without which
Some systems, like the Fedora and UBI container images, ship no `which`,
so `nvm current` printed `none` with a version in use,
which also let `nvm uninstall` remove the active version,
and `nvm which system` failed.
Look node up with `command -v`, ignoring aliases and functions,
via a new `nvm_executable_path`, which `nvm_has_executable` now uses too.

Co-authored-by: Iain <iain1970@protonmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-11-23 19:28:17 +00:00
Jordan Harband 16744eb47b [Tests] nvm_wget_with_url_credentials: add unit tests 2026-11-30 18:07:34 -08:00
Jordan Harband e9d1021653 [Tests] nvm_validate_min_version: add unit tests 2026-11-30 18:07:33 -08:00
Jordan Harband e3d685089d [Tests] nvm_type: add unit tests 2026-11-30 18:07:33 -08:00
Jordan Harband 41b489f702 [Tests] nvm_set_colors: add unit tests 2026-11-30 18:07:32 -08:00
Jordan Harband 0f09d20988 [Tests] nvm_select_lts_from_nvmrc: add unit tests 2026-11-30 18:07:31 -08:00
Jordan Harband f69c4e5e56 [Tests] nvm_resolve_local_alias: add unit tests 2026-11-30 18:07:30 -08:00
Jordan Harband fd1b2e1c08 [Tests] nvm_resolve_alias: add unit tests 2026-11-30 18:07:29 -08:00
Jordan Harband d870148d17 [Tests] nvm_replace_literal: add unit tests 2026-11-30 18:07:29 -08:00
Jordan Harband 28e240de70 [Tests] nvm_prune: add unit tests 2026-11-30 18:07:28 -08:00
Jordan Harband 318d9eca70 [Tests] nvm_process_parameters: add unit tests 2026-11-30 18:07:28 -08:00
Jordan Harband e09a43d096 [Tests] nvm_print_formatted_alias: add unit tests 2026-11-30 18:07:28 -08:00
Jordan Harband 87ba950406 [Tests] nvm_only_includes: add unit tests 2026-11-30 18:07:27 -08:00
Jordan Harband e279879469 [Tests] nvm_npmrc_bad_news_bears: add unit tests 2026-11-30 18:07:27 -08:00
Jordan Harband 55bdfd19dd [Tests] nvm_npm_global_modules: add unit tests 2026-11-30 18:07:27 -08:00
Jordan Harband 90965e3aae [Tests] nvm_npm: add unit tests 2026-11-30 18:07:26 -08:00
Jordan Harband d86011bb0b [Tests] nvm_normalize_version: add unit tests 2026-11-30 18:07:26 -08:00
Jordan Harband 9c71dec09a [Tests] nvm_needs_lts_status: add unit tests 2026-11-30 18:07:26 -08:00
Jordan Harband 9165bf1060 [Tests] nvm_match_version: add unit tests 2026-11-30 18:07:25 -08:00
Jordan Harband a95fabb521 [Tests] nvm_lts_status_path: add unit tests 2026-11-30 18:07:25 -08:00
Jordan Harband 72178b2d67 [Tests] nvm_ls_remote_index_tab: add unit tests 2026-11-30 18:07:25 -08:00
Jordan Harband 08763e43ef [Tests] nvm_list_aliases: add unit tests 2026-11-30 18:07:24 -08:00
Jordan Harband aa20d996b6 [Tests] nvm_is_zsh: add unit tests 2026-11-30 18:07:24 -08:00
Jordan Harband 4b12bf4a90 [Tests] nvm_is_version_selected: add unit tests 2026-11-30 18:07:24 -08:00
Jordan Harband 866a9d64c3 [Tests] nvm_is_version_or_alias: add unit tests 2026-11-30 18:07:23 -08:00
Jordan Harband fb17d36f31 [Tests] nvm_is_below_min_version: add unit tests 2026-11-30 18:07:23 -08:00
Jordan Harband 43a4ea2a12 [Tests] nvm_install_npm_if_needed: add unit tests 2026-11-30 18:07:23 -08:00
Jordan Harband e27de13dfa [Tests] nvm_grep: add unit tests 2026-11-30 18:07:23 -08:00
Jordan Harband e3cc267387 [Tests] nvm_get_remote_aliases: add unit tests 2026-11-30 18:07:22 -08:00
Jordan Harband 10dada17da [Tests] nvm_find_nvmrc: add unit tests 2026-11-30 18:07:22 -08:00
Jordan Harband 0527e34f99 [Tests] nvm_filter_min_versions: add unit tests 2026-11-30 18:07:22 -08:00
Jordan Harband b2ad63095f [Tests] nvm_filter_lts_versions: add unit tests 2026-11-30 18:07:21 -08:00
Jordan Harband 6bdf17fb4d [Tests] nvm_explain_excluded_version: add unit tests 2026-11-30 18:07:21 -08:00
Jordan Harband 300ab22dfb [Tests] nvm_err_with_colors: add unit tests 2026-11-30 18:07:21 -08:00
Jordan Harband 4c227362a4 [Tests] nvm_ensure_lts_status: add unit tests 2026-11-30 18:07:20 -08:00
Jordan Harband a5eef5568e [Tests] nvm_echo_with_colors: add unit tests 2026-11-30 18:07:20 -08:00
Jordan Harband 8baffe92e0 [Tests] nvm_cd_root: add unit tests 2026-11-30 18:07:20 -08:00
Jordan Harband 7773328bb5 [Tests] nvm_cache_dir: add unit tests 2026-11-30 18:07:19 -08:00