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