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.
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
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
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.
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>
`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>
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>
`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>
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.
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>