Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvm alias default isn't respected upon new tmux window/pane #3537

Open
Rican7 opened this issue Mar 1, 2025 · 9 comments
Open

nvm alias default isn't respected upon new tmux window/pane #3537

Rican7 opened this issue Mar 1, 2025 · 9 comments

Comments

@Rican7
Copy link

Rican7 commented Mar 1, 2025

Operating system and version:

Ubuntu 22.04.5 LTS; running via WSL1; on Windows 11 24H2 (OS Build 26100.3194)

nvm debug output:

nvm --version: v0.40.1
$TERM_PROGRAM: tmux
$SHELL: /usr/bin/bash
$SHLVL: 3
whoami: 'Rican7'
${HOME}: /mnt/c/Users/Trevor
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/Documents/Development/go/bin:${HOME}/Documents/Development/go/bin:/usr/local/go/bin:${NVM_DIR}/versions/node/v20.15.0/bin:./bin:vendor/bin:${HOME}/.composer/vendor/bin:${HOME}/.config/composer/vendor/bin:${HOME}/.rbenv/bin:${HOME}/.rbenv/shims:${HOME}/.phpenv/bin:${HOME}/.phpenv/shims:/usr/local/heroku/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:~/.local/bin:~/local/bin:/usr/bin:/usr/sbin:${HOME}/Documents/Development/go/bin:/usr/local/go/bin:${NVM_DIR}/versions/node/v20.15.0/bin:${HOME}/.asdf/shims:${HOME}/.asdf/bin:./bin:vendor/bin:${HOME}/.composer/vendor/bin:${HOME}/.config/composer/vendor/bin:${HOME}/.rbenv/bin:${HOME}/.rbenv/shims:${HOME}/.phpenv/bin:${HOME}/.phpenv/shims:/usr/local/heroku/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:~/.local/bin:~/local/bin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/Program Files/ctags:/mnt/c/Program Files/dotnet:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA app/NvDLISR:/mnt/c/Program Files/Docker/Docker/resources/bin:${HOME}/AppData/Local/Microsoft/WindowsApps:/snap/bin:/usr/local/packer/bin:/usr/local/packer/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 4.4.0-26100-Microsoft #1882-Microsoft Fri Jan 01 08:00:00 PST 2016 x86_64 x86_64 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Ubuntu 22.04.5 LTS
awk: /usr/bin/awk, GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)
curl: /usr/bin/curl, curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.18
wget: /usr/bin/wget, GNU Wget 1.21.2 built on linux-gnu.
git: /usr/bin/git, git version 2.42.0
grep: /usr/bin/grep, grep (GNU grep) 3.7
sed: /usr/bin/sed, sed (GNU sed) 4.8
cut: /usr/bin/cut, cut (GNU coreutils) 8.32
basename: /usr/bin/basename, basename (GNU coreutils) 8.32
rm: /usr/bin/rm, rm (GNU coreutils) 8.32
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.32
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.8.0
nvm current: v20.15.0
which node: ${NVM_DIR}/versions/node/v20.15.0/bin/node
which iojs:
which npm: ${NVM_DIR}/versions/node/v20.15.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v20.15.0
npm root -g: ${NVM_DIR}/versions/node/v20.15.0/lib/node_modules

nvm ls output:

        v16.9.1
       v16.20.1
       v16.20.2
       v18.18.0
       v18.18.2
       v18.20.3
->     v20.15.0
       v22.14.0
default -> lts/* (-> v22.14.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v22.14.0) (default)
stable -> 22.14 (-> v22.14.0) (default)
lts/* -> lts/jod (-> v22.14.0)
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
lts/hydrogen -> v18.20.7 (-> N/A)
lts/iron -> v20.18.3 (-> N/A)
lts/jod -> v22.14.0

How did you install nvm?

Install script in README:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

What steps did you perform?

  • Set a default version of node via nvm alias default lts/*
  • Opened a new pane/window in Tmux

Example:

Image

(I included dates so that it's obvious to tell the order of operations)

What happened?

The Node version set in the new bash shell wasn't the default as previously set for the new Tmux pane/window.

It works when opening a completely new terminal session, but not when opening a new pane/window. This isn't how any of my other runtime managers work, currently.

What did you expect to happen?

That the new default version would be respected upon new shell sessions in new Tmux panes/windows.

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

Nothing that touches Node or NVM, other than the included config as part of the install:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm # I: Not following: ./nvm.sh: openBinaryFile: does not exist (No such file or directory)
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
@Rican7
Copy link
Author

Rican7 commented Mar 1, 2025

This seems related to #2475, and may be due to #1315?

@ljharb
Copy link
Member

ljharb commented Mar 1, 2025

So, to clarify, the issue is that a new shell isn't using the default?

what is I: Not following: ./nvm.sh: openBinaryFile: does not exist (No such file or directory) in your profile snippet? that seems relevant.

@Rican7
Copy link
Author

Rican7 commented Mar 1, 2025

So, to clarify, the issue is that a new shell isn't using the default?

Yup! Exactly!

what is I: Not following: ./nvm.sh: openBinaryFile: does not exist (No such file or directory) in your profile snippet? that seems relevant.

lol, whoops! Didn't mean to copy that. That's a annotation in Vim, from ALE doing a lint via Shellcheck. It can't find that file because it's not in the working directory that I opened Vim from. 😅

@ljharb
Copy link
Member

ljharb commented Mar 1, 2025

so, it's worth noting that termux uses $PREFIX, and so does npm, so the two are kind of inherently incompatible (altho most of the time the conflict doesn't break anything).

what does nvm which output in the tmux shell? what if you nvm use, what's nvm current say after that?

@Rican7
Copy link
Author

Rican7 commented Mar 1, 2025

so, it's worth noting that termux uses $PREFIX, and so does npm, so the two are kind of inherently incompatible (altho most of the time the conflict doesn't break anything).

Yea, that's totally fair. I'm not using termux, though. Just tmux native (vanilla?).

what does nvm which output in the tmux shell? what if you nvm use, what's nvm current say after that?

Rican7@TNS-XPS-15-2018 ~ $ nvm which
No .nvmrc file found

Node Version Manager (v0.40.1)

 --- CLIPPED LONG HELP INFO HERE ---
Rican7@TNS-XPS-15-2018 ~ $ nvm use
No .nvmrc file found
Please see `nvm --help` or https://github.com/nvm-sh/nvm#nvmrc for more information.
Rican7@TNS-XPS-15-2018 ~ $ nvm current
v20.15.0

@ljharb
Copy link
Member

ljharb commented Mar 1, 2025

ah, sorry, i didn't realize those weren't the same thing :-)

presumably nvm use default would work (activate 22).

The only thing I can think of is that perhaps your tmux shell isn't sourcing the same profile file as your normal one - if you comment out the normal one's 3 sourcing lines, and open a tmux shell, is nvm still available?

@Rican7
Copy link
Author

Rican7 commented Mar 1, 2025

ah, sorry, i didn't realize those weren't the same thing :-)

All good!

presumably nvm use default would work (activate 22).

Yea, that's what I thought too! 😃

The only thing I can think of is that perhaps your tmux shell isn't sourcing the same profile file as your normal one - if you comment out the normal one's 3 sourcing lines, and open a tmux shell, is nvm still available?

Woah, weird, you're onto something! Commenting out those lines results in nvm no longer being available, but the node shim/version is still available... Something must be effecting my PATH.

Image

@Rican7
Copy link
Author

Rican7 commented Mar 1, 2025

Ok, going down a rabbit-hole here, and it looks like Tmux has special handling of the PATH variable that I need to understand to not think that this is nvm's fault here:

That being said, once nvm is sourced, shouldn't it be adding the current node default to the path? Or is that due to #1315?

I've never seen a runtime version tool behave like that.

@ljharb
Copy link
Member

ljharb commented Mar 1, 2025

nvm when sourced will indeed add itself to the front of the PATH, but if anything's modifying the PATH after it, that could shadow it.

tmux may indeed be doing something unique though which could cause a problem, though.

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

No branches or pull requests

2 participants