`nvm_check_global_modules` ran `npm --version` and `npm list -g` in `$PWD`,
so the project `.npmrc` applied, eg its `logs-dir` on npm v8.11 through v10.5.
The "npm unavailable" test put its fake npm on a relative `PATH` entry, which no longer resolves from `/`.
New Stuff
- select versions by category: `alpha`, `lts`, `non-lts`, `iojs`; exclude alphas by default
- `nvm alias`: store `--lts` and `--lts=<name>`
- record every node version's LTS status
- `nvm ls-remote`: annotate versions with the `node` alias and local aliases (#3920)
- add `nvm_has_italics`, to detect terminal italics support via terminfo
Bug Fixes
- `nvm`: treat a bare `--only` like an empty `--only=`
- `nvm_ls_remote`, `nvm_remote_version`: match dots between version components literally (#3982)
- `nvm_nvmrc_invalid_msg`: respect `--silent`
- `nvm_download`: pass `$NVM_AUTH_HEADER` to curl and GNU Wget in a config file, not as an argument
- `nvm_ls_remote_index_tab`, `nvm_remote_version`, `nvm_ls_cached`: pass the version pattern to grep with `-e`
- `nvm_die_on_prefix`: never let a project `.npmrc` choose which npmrc file `--delete-prefix` edits
- `nvm_download_artifact`: only put an archive in the cache once its checksum has passed
- `nvm_normalize_lts`, `nvm_ls_remote_index_tab`: keep untrusted text out of shell arithmetic and LTS aliases
- `nvm install`: keep nvm options after the version out of `./configure` (#3981)
- `nvm install`: apply `--alias`, `--default` and `--save` after every install (#3981)
- `nvm install`: don't leave `NVM_NO_PROGRESS` set in the caller's shell
- `nvm_get_default_packages`: ignore CRLF line endings (#3979)
- `install.sh`: ignore commented-out profile source lines (#3860)
- `nvm_print_implicit_alias`: keep `STABLE` bound, and `STABLE` and `UNSTABLE` independent of the caller (#3975)
- `nvm_ls`: treat a version dir with only hidden entries as empty (#3974)
- `ls`: list versions whose directory is a symlink (#3973)
- `nvm_die_on_prefix`: check a nonexistent prefix on Windows (#3972)
- `install.sh`: only write `$HOME` when `$NVM_DIR` is inside it (#3962)
- `nvm_is_version_or_alias`: reject uppercase LTS names in every locale
- `nvm_process_nvmrc`: don't show the content of a symlinked `.nvmrc`
- `nvm_write_nvmrc`: don't write through a symlinked `.nvmrc`
- `nvm_ls`: match `NVM_DIR` literally
- `nvm use`: do not pile up `PATH` entries in nested sessions (#3959)
- `nvm_filter_installed_versions`, `nvm_filter_lts_versions`, `nvm_record_lts_status`, `nvm_get_default_packages`: keep backslashes in `NVM_DIR` paths
- `nvm_strip_path`: preserve literal backslashes in `NVM_DIR` (#3958)
- `nvm_find_up`, `nvm_find_project_dir`: stop at a Windows drive root instead of looping forever (#3968)
- `nvm_ls_cached`: match dots in the version literally, and ignore a trailing dot (#3961)
- `install.sh`: `nvm_check_global_modules`: don't run a Windows npm under WSL (#3966)
- `nvm`: ignore option variables set by the caller
- `nvm reinstall-packages`: don't print `VERSION=''` in zsh
- `nvm_alias`, `nvm_ls_remote_index_tab`, `nvm use`: return the exit code of a failed check
- `nvm_print_versions`: don't mark `N/A` as installed
- `nvm_ls`: no blank line before `system` when nothing is installed
- `nvm_print_versions`: widen the version column for long versions
- `nvm_ls`: match a prerelease only up to a `.`
- `nvm_ls`: list every installed prerelease, in semver order
- `nvm uninstall`: only remove aliases that point at the uninstalled version
- `nvm_ls_cached`: only match whole version numbers
- `nvm debug`: don't let the shell read stdin when asked for its version
- `nvm_download`: with GNU Wget, follow only same-origin redirects when sending `$NVM_AUTH_HEADER`
- `nvm_download`: only send `$NVM_AUTH_HEADER` to URLs under a mirror it applies to
- `install.sh`: don't let a git repository in the current directory affect `git ls-remote`
- `nvm_remote_versions`: only consult io.js's version list for majors 1 through 3
- `nvm_remote_versions`: place io.js versions by major version, not at the literal `v4.0.0`
- `nvm.sh`: detect `NVM_DIR` without `$0`/`$_`; fall back to the default install location instead of the working directory
- `nvm_process_nvmrc_content`: reject control characters
- `nvm_download_artifact`, `nvm debug`: mask credentials in mirror URLs when printing them
- `nvm_install_binary`, `nvm_install_source`: only use a tarball that `nvm_download_artifact` put in the cache
- `nvm_download`, `nvm_get_latest`, `install.sh`: pass `-q` to curl first, so `.curlrc` is ignored again
- `nvm_is_version_installed`: fail when `nvm_version_path` fails
- `nvm use`, `nvm-exec`: stop option parsing at `--`
- `nvm install`: validate an inherited `NVM_MAKE_JOBS` like `-j`
- `nvm_is_natural_num`: reject anything but digits
- `nvm_remote_version`: match the requested version as a whole version component
- `install.sh`: a failed script-method download no longer clobbers the install or reports success
- `nvm_ls`: match the version pattern literally
- `bash_completion`: list alias and version names without expanding them
- `nvm_sanitize_auth_header`: strip newlines, so wrapped `base64` credentials work
- `nvm_cd`: bypass a user-defined `cd` function (#3836)
- `nvm use`: handle regex-special characters in `$NVM_DIR` (#3939)
- `install.sh`: start a new line before appending to a profile that does not end with one (#3952)
- Handle filesystem identity when checking path containment (#3921)
- `nvm alias`: do not drop output from background jobs on bash 3.2
- `nvm`: do not change or export the caller's `IFS`
- `nvm install`: do not remove the caller's `TMPDIR` after a failed download
- `nvm exec`/`nvm run`: do not treat filenames with digits as versions
Refactors
- `install.sh`: check profile lines through one comment-aware helper (#3976)
Robustness
- `nvm_nvmrc_invalid_msg`: only show an excerpt of the parsed content
- `install.sh`, `nvm uninstall`: pass the version to grep with `-e`
Performance
- `nvm_print_implicit_alias`: classify implicit aliases in one awk pass (#3980)
- `nvm_is_installed_exact_version`: also take the fast path for an exact prerelease
- `nvm_version_greater`, `nvm_version_greater_than_or_equal_to`: avoid `awk` where possible (#3949)
- `nvm_is_valid_version`, `nvm_validate_implicit_alias`: avoid forks (#3949)
- `nvm_echo`: use the `printf` shell builtin under zsh (#3949)
- `nvm_get_os`: read `/etc/os-release` instead of forking `uname -a` (#3949)
- `nvm_npmrc_bad_news_bears`: scan npmrc files without forking `grep` (#3949)
- `nvm_die_on_prefix`: detect the OS only when it is needed (#3949)
- `nvm_version`: resolve an exact, installed version without `nvm_ls` (#3949)
- `nvm_is_version_installed`: check the modern layout's path before the full lookup (#3949)
- `nvm_resolve_local_alias`: skip `nvm_version` for an exact, installed version (#3937)
- `nvm use`: skip re-resolving an exact, installed version (#3937)
Docs
- [readme] `cdnvm`: let nvm parse `.nvmrc`, so a symlinked `.nvmrc`'s content is not printed
- [readme] Fix a Docker warning from using Docker installation instructions (#3927)
- [readme] explain the misleading `npm install` error from `npm run test/fast` (#3944)
Misc
- [meta] `Makefile`: default `NVM_DIR` to the checkout when it is not set
- [meta] `release-notes.sh`: replace control characters in commit subjects
Tests
- make fast tests pass as root, without `sudo`, and without a terminal
- [actions] TOC: use `node/install` instead of `setup-node`
- pin `--lts` and `node` installs to end-of-life lines, so a new node release can't break them
- `bash_completion`: don't let zsh's `compinit` wait for an answer
- [actions] `tests-alpine`: time out jobs well before GitHub's 6-hour limit
- `nvm_download`: point the httpbin Authorization check at a configured mirror
- `nvm_get_arch_unofficial`: set `NVM_DIR` when sourcing `nvm.sh` in the chroots
- `nvm install v1 works`: get the version from `nvm_remote_version`, not the `ls-remote` display
- [actions] cache container images, verified against digests looked up live
- [actions] pull container images through Google's Docker Hub mirror
- [actions] never let an apt install wait on a prompt
- [actions] retry apt package installs through Ubuntu mirror outages
- add unit coverage for `nvm_version_greater_than_or_equal_to` (#3942)
- add unit tests for `nvm_version_greater_than_or_equal_to` (#3941)
- `nvm install --reinstall-packages-from`: mock the remote version instead of fetching it
- [actions] run the fast suite on macOS and WSL too
- make the fast suite pass on macOS
- [actions] rename `windows-npm` workflow to `windows-nvm`, since it tests `nvm install`
`nvm_do_install` checked for its `nvm.sh` and `bash_completion` source lines
with two separate regexes that each had to skip commented-out lines.
Move that into `nvm_profile_has_line`,
which strips whole-line comments before matching,
and test the `bash_completion` line and an already set up profile too.
`nvm_do_install` decided whether the profile already loads nvm, and its bash completion,
by grepping for `/nvm.sh` and `$NVM_DIR/bash_completion` anywhere in it,
so a commented-out line, the usual way to disable nvm, counted as present,
and reinstalling left the shell with no nvm.
Only count a line whose first non-blank character isn't `#`.
Fixes#1889.
Signed-off-by: Vaibhav Cheruvu <vaibhavsharma.c@gmail.com>
Co-authored-by: Vaibhav Cheruvu <vaibhavsharma.c@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
The profile line was built by replacing a leading `$HOME` with `sed`,
without a path boundary,
and with `$HOME` treated as a regex.
With `HOME=/home/me` and `NVM_DIR=/home/me2/nvm`,
or with `HOME=/` and `NVM_DIR=/usr/local/nvm`,
the profile got `export NVM_DIR="$HOME2/nvm"` or `export NVM_DIR="$HOMEusr/local/nvm"`,
which expand to the wrong directory,
so nvm does not load in new shells.
A `.` in `$HOME` matched any character,
a `:` in it broke the `sed` expression,
and a trailing slash on it left `$HOME.nvm`.
Match `$HOME` literally, as a whole path component,
and leave the path absolute when `$HOME` is empty.
Under WSL, `PATH` can include a Windows Node install, so `command -v npm` can find its `npm` shell shim, which then failed against Windows paths.
That npm is not a system node that nvm would shadow, so under WSL, skip an npm that has an `npm.cmd` beside it: both the Node installer and npm's own shims put one there.
Outside WSL (eg, Git Bash or Cygwin), a Windows npm is the system node, so the warning is kept.
Fixes#3700.
Signed-off-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-Authored-By: Codex <noreply@openai.com>
`install_nvm_from_git` checked whether `$NVM_INSTALL_VERSION` is a ref with a bare `git ls-remote`,
which discovers and loads the config of whatever repository contains the current directory.
That repository's `url.*.insteadOf` and `core.sshCommand` could then redirect or hijack the check,
unlike every other git command in the function,
which already passes `--git-dir="$INSTALL_DIR"/.git`.
Pass `--git-dir` here too;
`ls-remote` works even when that directory does not exist yet,
as on a fresh install
Discovered by Anthropic's OSS Scanner, as ANT-2026-JS4YHKRK; the scanner reported it as a vulnerability, but it is not one.
`install_nvm_from_git` passed `$NVM_INSTALL_VERSION` to grep as a bare argument,
and `nvm uninstall` did the same with the resolved version when looking for aliases that point to it,
so a value starting with `-` would have been parsed as grep options rather than as the pattern.
Neither value crosses a trust boundary
(the first is the user's own environment variable, and the second is an already-installed version, which never starts with `-`),
but every grep that receives a version should put it after `-e`,
which POSIX specifies and which nvm.sh already uses elsewhere
Discovered by Anthropic's OSS Scanner, alongside vulnerability ANT-2026-EN9DM7WC; this change is not itself a vulnerability fix.
curl only skips reading `.curlrc` when `-q` is its very first argument;
anywhere else, the config file has already been read by the time `-q` is seen.
a4f89c62 added `-q` to every curl call so that a user's `.curlrc` would not affect nvm,
but 6a3b1dd2 (v0.33.2)
put `--compressed` in front of it everywhere.
bd090ef7 (v0.40.0)
moved it back to the front in `nvm.sh`'s `nvm_download`,
and then 6d870d18 (v0.40.5) began building those arguments with `set --`,
prepending `--compressed` after `-q`,
so whenever curl supports compression, `-q` was second again.
`nvm_get_latest` and `install.sh`'s `nvm_download` have passed
`--compressed` before `-q` since v0.33.2.
Pass `-q` first in all three places.
Settings in a user's `.curlrc`
(such as a proxy, CA bundle, or `write-out`)
no longer apply to nvm's own curl calls,
as was intended,
and as in v0.40.0 through v0.40.4 for `nvm_download`;
the corresponding environment variables
(eg, `https_proxy`, `CURL_CA_BUNDLE`) still apply.
The existing `nvm_get_latest` test pinned the old argument order,
so its expectation is updated
Discovered by Anthropic's OSS Scanner, as ANT-2026-DESJ2ESZ; the scanner reported it as a vulnerability, but it is not one.
With the script install method,
`install_nvm_as_script` downloaded `nvm.sh`,
`nvm-exec`, and `bash_completion` directly over the installed files.
A dropped connection with curl left a truncated `nvm.sh`,
and any wget failure (even just being offline)
left all three files empty.
Its failure was also ignored by `nvm_do_install`,
which went on to edit the profile,
source the broken `nvm.sh`,
print the success message, and exit 0.
Now each file is downloaded to a temporary `.download` name,
every download is waited on
(by PID, rather than returning while other downloads may still be writing),
and the files are moved into place only once all of them have succeeded;
on failure,
the partial downloads are removed and the existing install is left untouched.
`nvm_do_install` now exits with
`install_nvm_as_script`'s failure status,
matching the git install method
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-8TH8YGY5; the scanner correctly classified it as not a vulnerability.
Bug Fixes
- `nvm_alias`, `nvm_version_path`: reject `..` path components
- `nvm_get_make_jobs`: count cores on platforms the `case` does not name
- `nvm-exec`: improve the no-version failure message
- `nvm use`: do not clobber `man`'s default search path (#3890)
- `nvm_err`, `nvm_err_with_colors`: do not fail when stderr is closed (#3907)
- `nvm_hash_reset`: only run `hash -r` where the shell supports it
- `nvm_alias`: unset zsh's `extendedglob` while reading an alias file (#3891)
- zsh: restore `nomatch` and `markdirs` rather than clobbering them
- `nvm --help`: render the set-colors legend in color (#3915)
- `nvm unload`: drop the undefined `nvm_format_help_message_colors`
- `nvm_get_mirror`: allow ports, userinfo, IPv6 hosts, and percent-encoding
- `nvm_sanitize_auth_header`: allow `~`, completing RFC 7235 `token68` (#3751)
Refactors
- `nvm --help`: extract the set-colors legend into `nvm_print_color_legend`
Performance
- Optimize nvm_tree_contains_path with in-memory POSIX parent-walk (#3912)
Docs
- [readme] document platforms with no official node binaries
- `install.sh`: Fix missing words in bash/zsh completion message (#3887)
- Remove stray closing HTML tag (#3919)
Misc
- [meta] remove CLAUDE.md symlink in favor of AGENTS.md (#3928)
- [meta] add `release-notes.sh`, the release notes generator
Tests
- homebrew/actions changed their default branch
- [actions] WSL: pin every distribution, and test the newest of each line
- `nvm_print_color_legend`: look up the function with `PATH` emptied
- `nvm_print_color_legend`: check for the function, not a same-named file
- `nvm_print_color_legend`: fix the `fast` suite on GNU userlands
- [actions] `release.yml`: provide `GH_TOKEN` so release-notes PR lookup can run
New Stuff
- `nvm install`: serialize concurrent installs of the same version
- `nvm install`: add `NVM_NO_SOURCE_FALLBACK` to disable the source fallback
Robustness
- `nvm install`: reject a structurally broken installed version
- `nvm_install_binary_extract`: replace a broken version dir atomically
- `install.sh`: `nvm_download`: avoid `eval` so arguments aren't re-parsed by the shell
Docs
- [readme] link every referenced person and project to its canonical page
Misc
- [Dev Deps] update `markdown-link-check`
Tests
- install_nvm_from_git: don't fail when master is at the latest release tag
`install.sh` has its own `nvm_download`,
which joined `"$@"` into a single string with `nvm_echo` and rewrote the curl-style flags with `sed`,
then ran the result through `eval command wget $ARGS`.
Flattening argv into a string is the root cause: every argument was re-parsed by the shell,
so any shell metacharacter in a legitimate value was interpreted rather than passed through.
An `$NVM_DIR` containing a space silently word-split and wrote to the wrong path,
an apostrophe or parentheses were a syntax error,
a glob character expanded against the cwd,
and an `$NVM_SOURCE` mirror URL with an `&` in its query string backgrounded `wget` and ran the remainder as a bogus command.
The `sed` rewrites were also unanchored substring replacements that would mangle a URL legitimately containing `-o `,
and `ARGS` was an undeclared global that `nvm_reset` never unset.
Translate the flags per-argument with a POSIX `set --` loop and invoke `command wget "$@"` instead,
so each argument stays a literal argv element.
This is the same shape `nvm.sh`'s `nvm_download` has used since 6d870d18,
and it stops the two implementations from diverging.
Unlike `nvm.sh`, no mirror-supplied data reaches this function:
its arguments come only from `$NVM_SOURCE`, `$NVM_INSTALL_GITHUB_REPO`, `$NVM_INSTALL_VERSION`, `$NVM_DIR`, `$XDG_CONFIG_HOME`, and `$HOME`, and `install.sh`'s `nvm_latest_version` is a hardcoded string rather than `nvm.sh`'s `nvm_get_latest`.
This is therefore a robustness fix and not a security one,
since the only party who can influence these arguments is the one already running the installer.
`nvm_has` matches shell functions and aliases,
but downloads now run via `command`, which skips them
- a `curl` shell function with no curl binary on the PATH would select the curl path and fail with exit 127,
instead of falling back to an available wget executable.
The new `nvm_has_executable` helper resolves names the same way `command` does, so downloader selection and execution agree.
zsh (and interactive bash with `expand_aliases`) bakes a preexisting `curl` alias into nvm's function bodies at source time,
and shell functions named `curl`/`wget` shadow the binaries at call time - either one breaks downloads.
Prefixing invocations with `command` bypasses both: here, `nvm_download`'s dispatch, `nvm_curl_version`, `nvm_curl_libz_support`, and the wget branch of `nvm_get_latest`;
the remaining bare `curl` invocations in `nvm_get_latest` and the install script are prefixed in a followup commit.
The tests that previously mocked curl/wget as shell functions now install fake executables on PATH instead,
via a shared `make_fake_curl` helper in `test/common.sh`,
and a new test asserts the bypass.
Refs #2923
[Tests] `install.sh`: add tests for PROFILE=/dev/null profile skip
Verify that when PROFILE="/dev/null" is set:
- The "Profile not found" warning is suppressed
- Profile modification is skipped as expected
Co-authored-by: Wes Todd <wes@wesleytodd.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
The script assumes that the name of the remote is `origin`, but this
is not the case if the user has set `clone.defaultRemoteName` to
another value in the ~/.gitconfig (or elsewhere in the configuration).
Adding `-o origin` ensures that the remote will be called `origin`
regardless of the `clone.defaultRemoteName` setting.
Per PR #3341:
- The minimum Git version this should work with is v1.7.10. (This is not
documented in the repo itself; it's just an implicit requirement.)
- The `--origin` option was added to `git clone` in commit 98a4fef3f2 which
was released in v1.2.5. From the diff of that commit, the `-o` option was
already available at that time. So this easily satisfies the above.
- A comment in #3341 indicates that `-o` was added in v1.1.0. I've not
verified this, but we probably don't need to track that down since by the
above we're already well within requirements.
New Stuff
- `install.sh`: add `$ZDOTDIR` to zsh search (#3458)
Fixes
- `reinstall-packages`: do not reinstall corepack (#3544)
- avoid bash-specific syntax (#3499)
- `install-latest-npm`: npm v11 is out
- `nvm_install_latest_npm`: avoid unbound variable (#3447)
- give a more helpful message when `lts` alias is mistakenly used (#3441)
- `nvm ls`, `nvm alias`, `nvm install`: error when an LTS name is invalid
- `nvm_normalize_lts`: error when an LTS name is not lowercase (#3417)
Documentation
- [readme] update link
- [readme] fix `--no-use` example (#3479)
- [readme] update copyright notice (#3507)
- [readme] note zsh-nvm's AUTO_USE option (#2670)
- [readme] add note about reloading zshrc after editing (#3052)
- [readme] Update shell profile file install notes (#2241)
- [readme] add docker tips (#2318)
- [readme] remove `avn` from readme (#3469)
- [readme] fnm -> nvm.fish (#2541)
Refactors
- prefer `case` over if/else chains
- combine `sed -e` invocations/arguments
Tests
- `nvm exec`/`nvm run`: add `--silent` tests (#1259)
- [actions] release test needs git tags
- migrate `installation_iojs` test suite to GitHub Actions (#3476)
- Migrate slow test suite from Travis CI (#3470)
- temporarily skip this failing travis test to unblock progress
- [actions] TOC: use latest LTS node
- `install.sh`: clean up `nvm_detect_profile` tests
- `nvm_detect_profile`: refactor (#3467)
- run urchin tests on pull requests (#3466)
- update mocks
- ensure that unit tests use only mocked LTS names
- [actions] use `node/install` instead of `node/run`
Meta
- disable blank issues
- update issue template
- add DCO (#3456)
- Rename .github/ISSUE_TEMPLATE.md to .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md (#3454)