nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nvm screws with path leading to warnings on shell startup

simylein opened this issue · comments

Operating system and version:

nvm debug output:

nvm --version: v0.39.7
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'frontend'
${HOME}: /home/frontend
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v22.1.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.2.15(1)-release (aarch64-unknown-linux-gnu)'
uname -a: 'Linux 6.1.0-20-arm64 #1 SMP Debian 6.1.85-1 (2024-04-11) aarch64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Debian GNU/Linux 12  
random-funcs:       srandom/random
regex-funcs:        internal
compiled limits:
sprintf buffer      8192
maximum-integer     2147483647
awk: /usr/bin/awk, mawk 1.3.4 20200120
curl: /usr/bin/curl, curl 7.88.1 (aarch64-unknown-linux-gnu) libcurl/7.88.1 OpenSSL/3.0.11 zlib/1.2.13 brotli/1.0.9 zstd/1.5.4 libidn2/2.3.3 libpsl/0.21.2 (+libidn2/2.3.3) libssh2/1.10.0 nghttp2/1.52.0 librtmp/2.3 OpenLDAP/2.5.13
wget: /usr/bin/wget, GNU Wget 1.21.3 built on linux-gnu.
git: /usr/bin/git, git version 2.39.2
grep: /usr/bin/grep, grep (GNU grep) 3.8
sed: /usr/bin/sed, sed (GNU sed) 4.9
cut: /usr/bin/cut, cut (GNU coreutils) 9.1
basename: /usr/bin/basename, basename (GNU coreutils) 9.1
rm: /usr/bin/rm, rm (GNU coreutils) 9.1
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 9.1
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.9.0
nvm current: v22.1.0
which node: ${NVM_DIR}/versions/node/v22.1.0/bin/node
which iojs: 
which npm: ${NVM_DIR}/versions/node/v22.1.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v22.1.0
npm root -g: ${NVM_DIR}/versions/node/v22.1.0/lib/node_modules

nvm ls output:

->      v22.1.0
default -> 22 (-> v22.1.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v22.1.0) (default)
stable -> 22.1 (-> v22.1.0) (default)
lts/* -> lts/iron (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.2 (-> N/A)
lts/iron -> v20.12.2 (-> N/A)

How did you install nvm?

install script in readme

What steps did you perform?

nothing, just installation

What happened?

it works, but every time my shell starts up it prints this warning

manpath: can't set the locale; make sure $LC_* and $LANG are correct

What did you expect to happen?

I expect that nvm does not screw with my path and therefore with my linux system.

Is there anything in any of your profile files that modifies the PATH?

only this global one which is default for any Debian system

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$(id -u)" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH

How is printing that warning "screwing with your path"?

To be clear, nvm's install script's entire purpose is to alter your PATH, so that node and npm can work.

I'm confused by this output in your nvm debug result:

random-funcs:       srandom/random
regex-funcs:        internal
compiled limits:
sprintf buffer      8192
maximum-integer     2147483647

nothing should be producing that; the preceding line should come from OS_VERSION="$(. /etc/os-release && echo "${NAME}" "${VERSION}")" on a debian system.

What modifications have you made to this system beyond the defaults?

How is printing that warning "screwing with your path"?

I think it might relate to #3144. If I install software, then afterwards other software on my system starts to complain, that is a red flag for me personally. (but maybe that's just me). Uninstalling did fix it, so at least it's not permanent.

To be clear, nvm's install script's entire purpose is to alter your PATH, so that node and npm can work.

I understand that, and this is what I want it to do.

I'm confused by this output in your nvm debug result:

random-funcs:       srandom/random
regex-funcs:        internal
compiled limits:
sprintf buffer      8192
maximum-integer     2147483647

nothing should be producing that; the preceding line should come from OS_VERSION="$(. /etc/os-release && echo "${NAME}" "${VERSION}")" on a debian system.

I just ran nvm debug, that's what it produced on my machine. Is there anything specific I can help you with?

What modifications have you made to this system beyond the defaults?

It's really a vanilla Debian image, at least that's what I like to believe Hetzner offers me.
Linux lazarus 6.1.0-20-arm64 #1 SMP Debian 6.1.85-1 (2024-04-11) aarch64 GNU/Linux
Beyond default software I installed: caddy, bun and umm well.... nvm.

The issue you linked was fixed in v0.39.5.

What does nvm_get_os output? what's echo $MANPATH both before and after loading nvm?

What does nvm_get_os output?

linux

what's echo $MANPATH both before and after loading nvm?

before: nothing, it's appears to be an empty string

after nothing, it's appears to be an empty string

If it helps, the issue appears only after I ran nvm install 22 before that it is not present (although nvm without any node versions is kinda boring)

And running this [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

also triggers manpath: can't set the locale; make sure $LC_* and $LANG are correct

hm, that's very confusing. which manpath?

hm, that's very confusing. which manpath?

/usr/bin/manpath

lol same as me, that's not helping.

https://stackoverflow.com/questions/45995530/manpath-cant-set-the-locale-make-sure-lc-and-lang-are-correct seems to suggest that there's some language/locale settings on your system that may need to be changed - I also see https://stackoverflow.com/questions/64660515/terminal-outputting-manpath-cant-set-the-locale-make-sure-lc-and-lang-ar which is a bit more nvm-specific and is a simpler fix.

I followed your links for a bit and found this link https://askubuntu.com/questions/33025/locale-settings-are-not-right-how-can-i-reset-them/1489608#1489608 which suggests turning off "set locale environment variables on startup" which appears to "resolve" the problem. I just don't understand why this was never a problem before and only became one when loading nvm. Also I kinda feel like I would want my terminal to set locale environment variables on startup. There must be reason it is on by default.
Screenshot 2024-05-08 at 08 33 10

Thank you for helping me debug this issue

I’m definitely not sure of the root problem here - nvm’s just using the manpath executable to provide node’s manpages, which is what is triggering the warning - but im glad you found a workaround.