mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-11-21 08:33:54 +03:00
`nvm_change_path` prepends the new version (instead of replacing the existing nvm path) when a system bin dir precedes an nvm path, to handle macOS `path_helper` reordering the `PATH` of nested sessions (#1652). However, the check matched a system dir followed by *any* nvm path. Once a stale nvm path sits after the system dirs (e.g. inherited by a nested shell, tmux, or an editor's terminal), the check stays true forever, so every `nvm use` prepends yet another entry and the previously used version is never removed from the `PATH`. Only consider the first nvm path: if it is not preceded by a system bin dir, replace it in place as usual. Fixes #3561