Commit Graph
2617 Commits
Author SHA1 Message Date
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
Jordan Harband c4bb986185 [Tests] nvm_binary_available: add unit tests 2026-11-30 18:07:19 -08:00
Oikantik Basu 74544c12f4 [Fix] nvm install: explain native Windows curl write failures
Refs #3391.
2026-11-24 19:09:58 +05:30
Hridhin Varkey Joseph 41041a99ca [Tests] nvm_check_file_permissions: symlinked directories and cycles are not traversed 2026-11-22 22:41:58 +05:30
thejesh23 35519ec047 [Fix] nvm reinstall-packages: fail when the version is not installed
`nvm reinstall-packages 99` resolved the version to `N/A` and kept going:
it told the user to run `nvm install N/A`,
printed "Reinstalling global packages from N/A..." and exited 0.
Only the case of an installed version excluded by `--only` returned early.

Now any unresolved version prints "Version '99' is not installed." and returns 3,
like `nvm install --reinstall-packages-from=`,
which already requires an installed version.

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: thejesh23 <35212698+thejesh23@users.noreply.github.com>
2026-11-22 08:26:23 -08:00
NUAAwqyandJordan Harband a66a5ae5d2 [Fix] nvm.sh: use NVM_-prefixed locals in the sourcing path
Sourcing nvm.sh fails when the caller has made readonly a variable that nvm.sh declares as a local,
such as `readonly VERSION` in a CI build script:
bash rejects the `local`, and dash exits.

Prefix the locals that sourcing and its `nvm use` reach.
The test derives the unprefixed local names from nvm.sh,
so a new collision fails it.

`nvm_install_default_packages` reported an invalid default-packages file by assigning `nvm`'s `EXIT_CODE` without declaring it.
It now declares its own, and `nvm install` uses its return status instead,
except 3, which means npm failed to install the packages and,
as before, does not fail the install.

Fixes #3584

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-11-28 06:30:00 +00:00
585b6ec915 [New] add prune command
`nvm prune` uninstalls every version except the newest install per major
(per minor with `--minor`, and always per minor for `v0.x`),
the current version, the `$NVM_DIR/current` symlink target,
and anything an alias resolves to.
It lists what it will remove and asks first;
`--dry-run` only lists, and `--force` skips the prompt.

Co-authored-by: Guillermo Esguerra <gesguerrab@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-02-23 13:21:38 -05:00
Peter Dave Hello eb0c8b95c8 [Tests] Verify explicit make jobs without redundant source builds
Exercise both argument orders and multiple job counts against the existing fake source fixture,
checking the actual build and install make arguments.
Use an isolated offline cache and a conflicting inherited job count to catch regressions that a successful real compilation alone cannot detect.

Keep a real source build with explicit jobs in each installation suite,
but remove the redundant serial compilation and make installation failures and version mismatches fail the test immediately.
2026-11-26 03:13:13 +08:00
Peter Dave HelloandJordan Harband bea27fbe0f [New] bash_completion: complete options and arguments in context
Parse words before the cursor once to offer flags, versions, and aliases
in the positions that accept them. Distinguish install options before
and after the version, and leave run and exec arguments to the shell.

Match local names literally. Account for Readline splitting at `=` and
quoting common prefixes. Give zsh the same candidates as raw strings so
its line editor can match, quote, and close arguments in its own syntax.

Check the offered flags against nvm help and cover argument boundaries,
including the actual arguments submitted by zsh after Tab completion.

Co-authored-by: Peter Dave Hello <hsu@peterdavehello.org>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-11-25 13:23:26 -08:00
Jordan Harband 3bf6686090 [Robustness] handle an overridden type
A `type` function or alias defined before nvm is sourced
hijacked `nvm_has` and `nvm_command_info`.
`nvm_has` now uses `command -v`;
`nvm_command_info` needs `type`'s output,
so it uses `builtin type` in zsh,
whose `command type` runs an external `type` that can't see shell functions.

Since `command -v` makes dash hash the command,
`nvm_command_info` also parses dash's and ksh's "tracked alias" output.

Fixes #2352.
2020-11-21 13:33:12 -08:00
Mike MilkmanandJordan Harband a858cc3e2f [readme] bash .nvmrc auto-switching: don't bypass another cd function
`cdnvm` calls `command cd`,
which skips any `cd` function defined by another tool,
like the one `rvm` uses to switch ruby versions.

Salvaged from #1066, which predates the README's `cdnvm` snippet.

Co-authored-by: Mike Milkman <mik356ua@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2016-04-19 15:56:45 +03:00