Skip to content

Set MANPATH starting with : - #3890

Merged
ljharb merged 1 commit into
nvm-sh:masterfrom
al0ksar:as-nvm-sh-fix
Sep 8, 2026
Merged

ljharb merged 1 commit into
nvm-sh:masterfrom
al0ksar:as-nvm-sh-fix

Conversation

@al0ksar

@al0ksar al0ksar commented Jul 27, 2026 •

Copy link
Copy Markdown

I recently updated from Ubuntu 24.04 to Ubuntu 26.04 and my man pages stopped working. Upon help from other people, found out that MANPATH should start with : instead of overriding the existing values by giving the path straight away. Found out the problem is in nvm.sh file and I just tried adding the : in the beginning, restarted the PC and it worked.

Before

alok@mylinux:~$ printenv | ag MANPATH
MANPATH=/home/alok/.nvm/versions/node/v24.15.0/share/man:/opt/testwell/ctc_v10.3.0/man
alok@mylinux:~$ man time
No manual entry for time

After

alok@mylinux:~$ printenv | ag MANPATH
MANPATH=:/home/alok/.nvm/versions/node/v24.15.0/share/man:/opt/testwell/ctc_v10.3.0/man
alok@mylinux:~$ man time
alok@mylinux:~$ 

It doesn't show but it did show man page for time.

ljharb added a commit to al0ksar/nvm that referenced this pull request Sep 6, 2026
`man` consults its own configured search path only when MANPATH holds an empty entry;
a list without one replaces the default outright.
`nvm use` produced exactly that,
so activating a version could hide every system man page.

Contribute the empty entry as a trailing one,
so that nvm's directory keeps precedence over the system's,
and only when the list has none already,
so that repeated `nvm use` calls are idempotent and an empty entry the user placed stays where they put it.

The `$(manpath)` snapshot this replaces went stale the moment man's configuration changed,
and cost a subprocess per `nvm use`.
It was also dead: `local MANPATH` scoped the assignment to `nvm()`,
so `export` did not outlive the call and MANPATH went untouched whenever it started out unset.
Only ksh, where `local` is not a builtin, ever ran it.

`nvm deactivate` now unsets MANPATH where nvm's was the only real entry,
rather than leaving a bare `:` behind.

Reported and diagnosed by @al0ksar in nvm-sh#3890, which used a leading empty entry instead.
That one accrues one more colon on every `nvm use`,
which `nvm deactivate` then leaves behind,
and it loses to the system's man pages wherever nvm's bin directory is not first on PATH.

Supersedes nvm-sh#2077.

Refs nvm-sh#3890
Refs nvm-sh#2077
`man` consults its own configured search path only when MANPATH holds an empty entry;
a list without one replaces the default outright.
`nvm use` produced exactly that,
so activating a version could hide every system man page.

Contribute the empty entry as a trailing one,
so that nvm's directory keeps precedence over the system's,
and only when the list has none already,
so that repeated `nvm use` calls are idempotent and an empty entry the user placed stays where they put it.

The `$(manpath)` snapshot this replaces went stale the moment man's configuration changed,
and cost a subprocess per `nvm use`.
It was also dead: `local MANPATH` scoped the assignment to `nvm()`,
so `export` did not outlive the call and MANPATH went untouched whenever it started out unset.
Only ksh, where `local` is not a builtin, ever ran it.

`nvm deactivate` now unsets MANPATH where nvm's was the only real entry,
rather than leaving a bare `:` behind.

Reported and diagnosed by @al0ksar in nvm-sh#3890, which used a leading empty entry instead.
That one accrues one more colon on every `nvm use`,
which `nvm deactivate` then leaves behind,
and it loses to the system's man pages wherever nvm's bin directory is not first on PATH.

Supersedes nvm-sh#2077.

Refs nvm-sh#3890
Refs nvm-sh#2077
@ljharb
ljharb merged commit e361b93 into nvm-sh:master Sep 8, 2026
298 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.

3 participants