Skip to content

[Fix] nvm_err, nvm_err_with_colors: do not fail when stderr is closed - #3907

Merged
ljharb merged 1 commit into
nvm-sh:masterfrom
lazerg:fix/nvm-err-closed-stderr
Sep 4, 2026
Merged

ljharb merged 1 commit into
nvm-sh:masterfrom
lazerg:fix/nvm-err-closed-stderr

Conversation

@lazerg

@lazerg lazerg commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

When a caller closes stderr instead of redirecting it to /dev/null, which Ruby's IO.popen(..., err: :close) and similar APIs do, the >&2 redirection in nvm_err fails, so nvm_err returns non-zero. nvm_compare_checksum ends with nvm_err 'Checksums matched!', so a successful checksum then reports failure and the install is aborted.

Running the redirection in a subshell keeps that failure out of the caller. It also matters in zsh, which aborts the whole shell when its own diagnostic about the failed redirection cannot be written either.

Fixes #3906

@lazerg
lazerg force-pushed the fix/nvm-err-closed-stderr branch from 8658bbc to 64f29cf Compare August 25, 2026 17:52
Jessdanie94

This comment was marked as spam.

Jessdanie94

This comment was marked as spam.

@ljharb
ljharb force-pushed the fix/nvm-err-closed-stderr branch from 64f29cf to b0db1fb Compare September 4, 2026 05:57
@ljharb
ljharb force-pushed the fix/nvm-err-closed-stderr branch from b0db1fb to ccb49e5 Compare September 4, 2026 21:10
@ljharb
ljharb merged commit ccb49e5 into nvm-sh:master Sep 4, 2026
363 of 366 checks passed
schnare22

This comment was marked as spam.

ljharb added a commit that referenced this pull request Sep 21, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nvm_err fails when stderr is closed

4 participants