Schniz / fnm

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

thread 'main' panicked on directory change with .node-version file #1039

Open db-it opened 9 months ago

db-it commented 9 months ago

When I change into a directory (or run any other command in that directory) with a .node-version or .nvmrc file I see this error:

thread 'main' panicked at 'Can't write output: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', src/commands/use.rs:93:13
stack backtrace:
   0:        0x10fc180c4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h995071f37c4297fa
   1:        0x10fc5b55b - core::fmt::write::haa54bb809952c8df
   2:        0x10fc23530 - std::io::Write::write_fmt::h1ac6c534dd14cec3
   3:        0x10fc17ee0 - std::sys_common::backtrace::print::h9da681148c637fa0
   4:        0x10fc24285 - std::panicking::default_hook::{{closure}}::h144fadd74c786af0
   5:        0x10fc24061 - std::panicking::default_hook::h7fa009e6d0ab057f
   6:        0x10fc2488a - std::panicking::rust_panic_with_hook::h577cd597b640ab15
   7:        0x10fc18393 - std::panicking::begin_panic_handler::{{closure}}::h7871cc079a6372f9
   8:        0x10fc18199 - std::sys_common::backtrace::__rust_end_short_backtrace::h081cf5424fb194f1
   9:        0x10fc2443d - _rust_begin_unwind
  10:        0x10fc7f163 - core::panicking::panic_fmt::hc3516b342b02e9d2
  11:        0x10fc7eee5 - core::result::unwrap_failed::h4495a6358bafc219
  12:        0x10f8a141c - <fnm::commands::use::Use as fnm::commands::command::Command>::apply::habf4439dced7e6fa
  13:        0x10f89f849 - fnm::commands::command::Command::call::h41fc020c37a8c5c1
  14:        0x10f8ae1e3 - fnm::cli::SubCommand::call::h0e237f440f6007fb
  15:        0x10f8aa5e1 - fnm::main::hae0b89af2c5711e6
  16:        0x10f8a3d76 - std::sys_common::backtrace::__rust_begin_short_backtrace::h90780fbba7d60fa3
  17:        0x10f8a3d8c - std::rt::lang_start::{{closure}}::hfd1de9ba5d3b2407
  18:        0x10fc24324 - std::panicking::try::h843812d96c4734bf
  19:        0x10fc4707e - std::rt::lang_start_internal::h70512f2e0a0494ec
  20:        0x10f8ab04c - _main
  21:     0x7ff81152741f - <unknown>

When I remove the .node-version file everything works fine. I can manually switch node versions by running fnm use 18.

I'm using

I installed fnm via homebrew and created ~/.config/fish/conf.d/fnm.fish with content fnm env --use-on-cd | source.

db-it commented 9 months ago

I tested this with bash and it's working without any problems.

kalvin807 commented 6 months ago

I also have this problem on fish. and it seems only happen when the node-version is < v18? (tested on node v20, v18, v16 only v16 has this error ) but on zsh it worked fine.

trace

❯ thread 'main' panicked at 'Can't write output: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', src/commands/use.rs:93:13
stack backtrace:
   0:        0x10083d824 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4ad3e9225f7521e9
   1:        0x10087bd9c - core::fmt::write::hd596d2031660b392
   2:        0x100857344 - std::io::Write::write_fmt::h2c992930f1478641
   3:        0x10083d62c - std::sys_common::backtrace::print::haf9902f09b134a96
   4:        0x100857e4c - std::panicking::default_hook::{{closure}}::h7808808df9612efd
   5:        0x100857bb8 - std::panicking::default_hook::h01526266ddbcf080
   6:        0x1008583d4 - std::panicking::rust_panic_with_hook::hf80c108ff425fa61
   7:        0x10083e18c - std::panicking::begin_panic_handler::{{closure}}::h5df3e10b49e527bd
   8:        0x10083d918 - std::sys_common::backtrace::__rust_end_short_backtrace::hece657cf8f4082b7
   9:        0x100857ff4 - _rust_begin_unwind
  10:        0x100894ee4 - core::panicking::panic_fmt::hb9fc09aa98cf5e3e
  11:        0x100894eb0 - core::result::unwrap_failed::hc4fcbf7d94a2a964
  12:        0x10053932c - <fnm::commands::use::Use as fnm::commands::command::Command>::apply::h9a61e925025264da
  13:        0x100537e9c - fnm::commands::command::Command::call::h567d184f58fe5e46
  14:        0x10052bf84 - fnm::cli::SubCommand::call::h628d69a2ff2b2bbe
  15:        0x1004fee38 - fnm::main::h68e18e58ed240848
  16:        0x100529948 - std::sys_common::backtrace::__rust_begin_short_backtrace::h98201f8a5b93919a
  17:        0x1005432fc - std::rt::lang_start::{{closure}}::h641c1c4df043f284
  18:        0x100856854 - std::rt::lang_start_internal::h3938ec785a4c1449
  19:        0x1004ff0f4 - _main
db-it commented 5 months ago

I was able to narrow down the problem. It seems to be a problem with the fish plugin ilancosman/tide@v5. I uninstalled tide and the error is gone.

@kalvin807 Do you have tide installed too? Can you confirm the error is gone, if you uninstall it?

Does anyone have any idea what the problem between the two tools might be?

db-it commented 5 months ago

The problem also persists with IlanCosman/tide@v6.

chrisdl commented 2 months ago

I'm having this issue as well. macOS, fish, and node 20.12.2. It doesn't seem to break anything just an annoying printout. It is happening for both .nvmrc and .node-version files.

officialpiyush commented 1 month ago

I'm having this issue as well. macOS, fish, and node 20.12.2. It doesn't seem to break anything just an annoying printout. It is happening for both .nvmrc and .node-version files.

Having the same issue as @chrisdl, fnm prints out Using Node vx.x.x on every command. For now, I have changed the command in the fnm.fish file to fnm env --use-on-cd | source 1>/dev/null, so now it only prints it when we first cd into the directory.