From 6cca9d508278a2dad6a02bdd81183ee4ac71ad4d Mon Sep 17 00:00:00 2001 From: branchseer Date: Tue, 4 Nov 2025 14:30:13 +0800 Subject: [PATCH 1/4] chore: trace not-found program's metadata --- Cargo.lock | 1 + crates/fspy/Cargo.toml | 1 + crates/fspy/src/command.rs | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad98152a..fe52816e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -999,6 +999,7 @@ dependencies = [ "tempfile", "thiserror 2.0.17", "tokio", + "tracing", "which", "winapi", "winsafe 0.0.24", diff --git a/crates/fspy/Cargo.toml b/crates/fspy/Cargo.toml index bd059218..660e4d38 100644 --- a/crates/fspy/Cargo.toml +++ b/crates/fspy/Cargo.toml @@ -18,6 +18,7 @@ rand = { workspace = true } tempfile = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["net", "process", "io-util", "sync"] } +tracing = { workspace = true } which = { workspace = true } xxhash-rust = { workspace = true } diff --git a/crates/fspy/src/command.rs b/crates/fspy/src/command.rs index c50b7ab5..c60f2b83 100644 --- a/crates/fspy/src/command.rs +++ b/crates/fspy/src/command.rs @@ -169,12 +169,22 @@ impl Command { std::env::current_dir().expect("failed to get current dir") }; self.program = which::which_in(self.program.as_os_str(), path_env, &cwd) - .map_err(|err| SpawnError::WhichError { + .map_err(|err| { + tracing::error!( + "failed to resolve program {:?} with PATH={:?} under cwd({:?}): {}. Metadata of program: {:?}", + self.program, + path_env, + cwd, + err, + std::fs::metadata(&self.program) + ); + SpawnError::WhichError { program: self.program.clone(), path: path_env.map(OsStr::to_owned), cwd, cause: err, - })? + } + })? .into_os_string(); Ok(()) } From b11dee581cee47330b65a818e4c5f2a45d220a5e Mon Sep 17 00:00:00 2001 From: branchseer Date: Tue, 4 Nov 2025 15:51:46 +0800 Subject: [PATCH 2/4] enable tracing on which-rs --- Cargo.lock | 1 + crates/fspy/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index fe52816e..7aa48d7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3524,6 +3524,7 @@ dependencies = [ "either", "env_home", "rustix 1.1.2", + "tracing", "winsafe 0.0.19", ] diff --git a/crates/fspy/Cargo.toml b/crates/fspy/Cargo.toml index 660e4d38..144195cc 100644 --- a/crates/fspy/Cargo.toml +++ b/crates/fspy/Cargo.toml @@ -19,7 +19,7 @@ tempfile = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["net", "process", "io-util", "sync"] } tracing = { workspace = true } -which = { workspace = true } +which = { workspace = true, features = ["tracing"] } xxhash-rust = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] From 98801adafa8820dca52102b02e1b378165441375 Mon Sep 17 00:00:00 2001 From: branchseer Date: Tue, 4 Nov 2025 16:15:48 +0800 Subject: [PATCH 3/4] bump which --- Cargo.lock | 5 ++--- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7aa48d7d..5c840bec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3517,11 +3517,10 @@ dependencies = [ [[package]] name = "which" -version = "7.0.3" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762" +checksum = "d3fabb953106c3c8eea8306e4393700d7657561cb43122571b172bbfb7c7ba1d" dependencies = [ - "either", "env_home", "rustix 1.1.2", "tracing", diff --git a/Cargo.toml b/Cargo.toml index de93a270..844946f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -115,7 +115,7 @@ vite_path = { path = "crates/vite_path" } vite_str = { path = "crates/vite_str" } vite_workspace = { path = "crates/vite_workspace" } wax = "0.6.0" -which = "7.0.3" +which = "8.0.0" widestring = "1.2.0" winapi = "0.3.9" winsafe = { version = "0.0.24", features = ["kernel"] } From 1a13c9bf887409103835d5ec8e74eb515ce5c81c Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 5 Nov 2025 16:39:37 +0800 Subject: [PATCH 4/4] remove tracing code --- Cargo.lock | 1 - crates/fspy/Cargo.toml | 1 - crates/fspy/src/command.rs | 14 ++------------ 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c840bec..b6adb06d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -999,7 +999,6 @@ dependencies = [ "tempfile", "thiserror 2.0.17", "tokio", - "tracing", "which", "winapi", "winsafe 0.0.24", diff --git a/crates/fspy/Cargo.toml b/crates/fspy/Cargo.toml index 144195cc..92d484b3 100644 --- a/crates/fspy/Cargo.toml +++ b/crates/fspy/Cargo.toml @@ -18,7 +18,6 @@ rand = { workspace = true } tempfile = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["net", "process", "io-util", "sync"] } -tracing = { workspace = true } which = { workspace = true, features = ["tracing"] } xxhash-rust = { workspace = true } diff --git a/crates/fspy/src/command.rs b/crates/fspy/src/command.rs index c60f2b83..c50b7ab5 100644 --- a/crates/fspy/src/command.rs +++ b/crates/fspy/src/command.rs @@ -169,22 +169,12 @@ impl Command { std::env::current_dir().expect("failed to get current dir") }; self.program = which::which_in(self.program.as_os_str(), path_env, &cwd) - .map_err(|err| { - tracing::error!( - "failed to resolve program {:?} with PATH={:?} under cwd({:?}): {}. Metadata of program: {:?}", - self.program, - path_env, - cwd, - err, - std::fs::metadata(&self.program) - ); - SpawnError::WhichError { + .map_err(|err| SpawnError::WhichError { program: self.program.clone(), path: path_env.map(OsStr::to_owned), cwd, cause: err, - } - })? + })? .into_os_string(); Ok(()) }