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