Schniz / fnm

🚀 Fast and simple Node.js version manager, built in Rust
https://fnm.vercel.app
GNU General Public License v3.0
17.93k stars 458 forks source link

command node not found #427

Open r17x opened 3 years ago

r17x commented 3 years ago

Issue

I have been following how to integrate fnm with zsh and I use fnm normally but when I quit from vim, node command not found, so I check fnm current, it's show the current version of node but can execute command from node.

Produces

❯ node -v
zsh: command not found: node
❯ fnm current
v14.16.0
❯ fnm use v14.16.0
❯ fnm list
* v12.22.0
* v14.16.0 default
* system
❯ fnm current
v14.16.0
❯ node -v
zsh: command not found: node

OS Information

OS: macOS 11.2.3 20D91 x86_64
Host: MacBookPro15,4
Kernel: 20.3.0
Uptime: 2 days, 9 hours, 13 mins
Packages: 97 (brew)
Shell: zsh 5.8
Resolution: 1440x900@2x
DE: Aqua
WM: Rectangle
Terminal: iTerm2
Terminal Font: FiraCodeNerdFontCompleteM-Regular 11
CPU: Intel i5-8257U (8) @ 1.40GHz
GPU: Intel Iris Plus Graphics 645
Memory: 5641MiB / 8192MiB

Zsh Configuration

 277   │ eval "$(fnm env)"
 278   │
 279   │ # it's brew but update after install packages
 280   │ function bruw() {
 281   │     HOMEBREW_NO_AUTO_UPDATE=1 brew "$@" && brew update
 282   │ }
 283   │
 284   │ alias ls="ls -G"
 285   │ alias brewup='brew update; brew upgrade; brew prune; brew cleanup; brew doctor'
 286   │
 287   │ alias cat=bat
 288   │ alias l='ls -l'
 289   │ alias la='ls -a'
 290   │ alias lla='ls -la'
 291   │ alias lt='ls --tree'

See detail zsh configuration here

Schniz commented 3 years ago

Can you please show me the output of the following commands:

echo $PATH
env | grep FNM_
r17x commented 3 years ago

@Schniz

❯ echo $PATH
/Users/r17/perl5/bin:/Users/r17/.yarn/bin:/Users/r17/.config/yarn/global/node_modules/.bin:/var/folders/p8/p4d4n5l91t5g4cjrv4kp9t1h0000gp/T/fnm_multishells/7940_1617982869850/bin:/Users/r17/.zinit/polaris/bin:/Users/r17/.fnm:/usr/local/bin:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/bin/core_perl/:/Users/r17/.local/bin:/Users/r17/scripts/bin:/usr/local/opt/fzf/bin:/Users/r17/go/bin:/usr/local/opt/go/libexec/bin
❯ env G FNM_
FNM_HOME=/Users/r17/.fnm
FNM_MULTISHELL_PATH=/var/folders/p8/p4d4n5l91t5g4cjrv4kp9t1h0000gp/T/fnm_multishells/7940_1617982869850
FNM_DIR=/Users/r17/.fnm
FNM_LOGLEVEL=info
FNM_NODE_DIST_MIRROR=https://nodejs.org/dist
FNM_ARCH=x64
❯ node -v
zsh: command not found: node
r17x commented 3 years ago

@Schniz

maybe this is will help how to solve this issue

❯ fnm list
* v12.22.0
* v14.16.0
* v14.16.1
* system
❯ for version in $(fnm list); do
case $version in
\*|system) ;;
*) echo "using node $version" && RUST_BACKTRACE=full fnm exec --using=$version node --version;;
esac
done;
using node v12.22.0
thread 'main' panicked at 'Can't spawn program: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/commands/exec.rs:70:14
stack backtrace:
   0:        0x100be981e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h04abbaabf148650a
   1:        0x100c295ee - core::fmt::write::h14dac7cadec1cc70
   2:        0x100be937a - std::io::Write::write_fmt::hfaf2e10dfdcc61d8
   3:        0x100c06b39 - std::panicking::default_hook::{{closure}}::h350fee0bf60f2674
   4:        0x100c066ab - std::panicking::default_hook::h0b4e3bc46e6dcb8d
   5:        0x100c070ca - std::panicking::rust_panic_with_hook::h8cdc0a575f4a5a7b
   6:        0x100be9fe5 - std::panicking::begin_panic_handler::{{closure}}::h7a7b30fd1c313876
   7:        0x100be9968 - std::sys_common::backtrace::__rust_end_short_backtrace::h2e099be83c81509d
   8:        0x100c06c43 - _rust_begin_unwind
   9:        0x100c374af - core::panicking::panic_fmt::h4f63e4f6b62b650b
  10:        0x100c37015 - core::result::unwrap_failed::hc2a56d017349147e
  11:        0x1008616bf - fnm::commands::command::Command::call::hcfbb5e46bb897282
  12:        0x10087fd15 - fnm::cli::SubCommand::call::hf453d893efaf23b3
  13:        0x10087d7b1 - fnm::main::h62fde99382031ed2
  14:        0x10085de3a - std::sys_common::backtrace::__rust_begin_short_backtrace::h300dff8753d5b931
  15:        0x10085de6c - std::rt::lang_start::{{closure}}::hfe46e79d78ea463e
  16:        0x100c0b5e0 - std::rt::lang_start_internal::hf4b96bfc8c02c8b0
  17:        0x10087de49 - _main
using node v14.16.0
thread 'main' panicked at 'Can't spawn program: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/commands/exec.rs:70:14
stack backtrace:
   0:        0x10d67e81e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h04abbaabf148650a
   1:        0x10d6be5ee - core::fmt::write::h14dac7cadec1cc70
   2:        0x10d67e37a - std::io::Write::write_fmt::hfaf2e10dfdcc61d8
   3:        0x10d69bb39 - std::panicking::default_hook::{{closure}}::h350fee0bf60f2674
   4:        0x10d69b6ab - std::panicking::default_hook::h0b4e3bc46e6dcb8d
   5:        0x10d69c0ca - std::panicking::rust_panic_with_hook::h8cdc0a575f4a5a7b
   6:        0x10d67efe5 - std::panicking::begin_panic_handler::{{closure}}::h7a7b30fd1c313876
   7:        0x10d67e968 - std::sys_common::backtrace::__rust_end_short_backtrace::h2e099be83c81509d
   8:        0x10d69bc43 - _rust_begin_unwind
   9:        0x10d6cc4af - core::panicking::panic_fmt::h4f63e4f6b62b650b
  10:        0x10d6cc015 - core::result::unwrap_failed::hc2a56d017349147e
  11:        0x10d2f66bf - fnm::commands::command::Command::call::hcfbb5e46bb897282
  12:        0x10d314d15 - fnm::cli::SubCommand::call::hf453d893efaf23b3
  13:        0x10d3127b1 - fnm::main::h62fde99382031ed2
  14:        0x10d2f2e3a - std::sys_common::backtrace::__rust_begin_short_backtrace::h300dff8753d5b931
  15:        0x10d2f2e6c - std::rt::lang_start::{{closure}}::hfe46e79d78ea463e
  16:        0x10d6a05e0 - std::rt::lang_start_internal::hf4b96bfc8c02c8b0
  17:        0x10d312e49 - _main
using node v14.16.1
thread 'main' panicked at 'Can't spawn program: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/commands/exec.rs:70:14
stack backtrace:
   0:        0x108abf81e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h04abbaabf148650a
   1:        0x108aff5ee - core::fmt::write::h14dac7cadec1cc70
   2:        0x108abf37a - std::io::Write::write_fmt::hfaf2e10dfdcc61d8
   3:        0x108adcb39 - std::panicking::default_hook::{{closure}}::h350fee0bf60f2674
   4:        0x108adc6ab - std::panicking::default_hook::h0b4e3bc46e6dcb8d
   5:        0x108add0ca - std::panicking::rust_panic_with_hook::h8cdc0a575f4a5a7b
   6:        0x108abffe5 - std::panicking::begin_panic_handler::{{closure}}::h7a7b30fd1c313876
   7:        0x108abf968 - std::sys_common::backtrace::__rust_end_short_backtrace::h2e099be83c81509d
   8:        0x108adcc43 - _rust_begin_unwind
   9:        0x108b0d4af - core::panicking::panic_fmt::h4f63e4f6b62b650b
  10:        0x108b0d015 - core::result::unwrap_failed::hc2a56d017349147e
  11:        0x1087376bf - fnm::commands::command::Command::call::hcfbb5e46bb897282
  12:        0x108755d15 - fnm::cli::SubCommand::call::hf453d893efaf23b3
  13:        0x1087537b1 - fnm::main::h62fde99382031ed2
  14:        0x108733e3a - std::sys_common::backtrace::__rust_begin_short_backtrace::h300dff8753d5b931
  15:        0x108733e6c - std::rt::lang_start::{{closure}}::hfe46e79d78ea463e
  16:        0x108ae15e0 - std::rt::lang_start_internal::hf4b96bfc8c02c8b0
  17:        0x108753e49 - _main

~                                                                                                                             02:51:30
❯
Schniz commented 3 years ago

Can you

ls $FNM_MULTISHELL_PATH
ls -l $FNM_MULTISHELL_PATH/bin

? 😃

r17x commented 3 years ago

@Schniz
this is

❯ ls $FNM_MULTISHELL_PATH
/var/folders/p8/p4d4n5l91t5g4cjrv4kp9t1h0000gp/T/fnm_multishells/25658_1618258813600
❯ ls -l $FNM_MULTISHELL_PATH/bin

ls: /var/folders/p8/p4d4n5l91t5g4cjrv4kp9t1h0000gp/T/fnm_multishells/25658_1618258813600/bin: No such file or directory
Schniz commented 3 years ago

❯ ls $FNM_MULTISHELL_PATH /var/folders/p8/p4d4n5l91t5g4cjrv4kp9t1h0000gp/T/fnm_multishells/25658_1618258813600

this is weird. can you please

ls -lah $FNM_MULTISHELL_PATH

?

r17x commented 3 years ago

@Schniz I was uninstall all of version node cause i need to run node.js. so I install again

❯ ls -lah $FNM_MULTISHELL_PATH
lrwxr-xr-x  1 r17  staff    31B Apr 13 18:45 /var/folders/p8/p4d4n5l91t5g4cjrv4kp9t1h0000gp/T/fnm_multishells/53168_1618314313734 -> /Users/r17/.fnm/aliases/default
❯ fnm list
* v10.24.1
* v14.16.1
* system
r17x commented 3 years ago

@Schniz I have been try to use in another machine, I found some clues. bin directory of node version is missing, my assume is deleted by (i dunno who deleted) in sometimes.

~/.fnm/node-versions/v12.22.1/installation 18:47:08 ❯

TimonVS commented 2 years ago

I have the same issue, but the behavior is slightly different for me. Sometimes when I open a shell, or come back to a shell that has been open for a while, node and npm won't work (command not found). I noticed that the fnm_multishells bin directory in $PATH would actually be non-existent. Opening a new shell (new tab or running zsh) fixes it (uses a different fnm_multishells bin path).

I was still on 1.25, but upgraded to see if the latest version (1.29.2) would fix it, but the issue is still there. Interestingly enough, it seems like my issues started when I installed Warp. I haven't actually used Warp much. I have an invite for Warp if you want to do some testing with it.

Terminal output ``` λ ~/Code/Cimpress/dex-component-library/ main* node zsh: command not found: node λ ~/Code/Cimpress/dex-component-library/ main* echo $PATH /Users/timon.vanspronsen/.deno/bin:/var/folders/zz/k_8ldk0d1s54527vdn3vmd4h0000gn/T/fnm_multishells/6083_1642666358403/bin:/Users/timon.vanspronsen/.fnm:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/timon.vanspronsen/.deno/bin:/var/folders/zz/k_8ldk0d1s54527vdn3vmd4h0000gn/T/fnm_multishells/2363_1642665296707/bin:/Users/timon.vanspronsen/.fnm λ ~/Code/Cimpress/dex-component-library/ main* ls -la /var/folders/zz/k_8ldk0d1s54527vdn3vmd4h0000gn/T/fnm_multishells/6083_1642666358403/bin ls: /var/folders/zz/k_8ldk0d1s54527vdn3vmd4h0000gn/T/fnm_multishells/6083_1642666358403/bin: No such file or directory λ ~/Code/Cimpress/dex-component-library/ main* fnm current none λ ~/Code/Cimpress/dex-component-library/ main* ls $FNM_MULTISHELL_PATH ls: /var/folders/zz/k_8ldk0d1s54527vdn3vmd4h0000gn/T/fnm_multishells/6083_1642666358403: No such file or directory λ ~/Code/Cimpress/dex-component-library/ main* ls -l $FNM_MULTISHELL_PATH/bin ls: /var/folders/zz/k_8ldk0d1s54527vdn3vmd4h0000gn/T/fnm_multishells/6083_1642666358403/bin: No such file or directory λ ~/Code/Cimpress/dex-component-library/ main* env | grep FNM_ FNM_NODE_DIST_MIRROR=https://nodejs.org/dist FNM_ARCH=x64 FNM_LOGLEVEL=info FNM_DIR=/Users/timon.vanspronsen/.fnm FNM_MULTISHELL_PATH=/var/folders/zz/k_8ldk0d1s54527vdn3vmd4h0000gn/T/fnm_multishells/6083_1642666358403 FNM_VERSION_FILE_STRATEGY=local ```
Schniz commented 2 years ago

yeah, I need to merge #638 because I'm using it for a while 🥲

Schniz commented 2 years ago

but I think it is not related to this issue

carlospliego commented 2 years ago

This is still an issue for me.

ReAlign commented 2 years ago

I am try fnm default v12.22.0, and then node -v is effective.

maybe should use fnm default <version>, not fnm use <version>,my fnm under @1.28.1


I guess fnm use <version> just effective in current shell, when open a new shell, it lose efficacy.


there is a gif show my zsh terminal works:

Kapture 2022-03-29 at 14 00 29