Skip to content

Commit f6f7962

Browse files
committed
fix(env): remove misleading PATH position check in vp env doctor
Replace the position-based PATH check with a simple presence check. The old code warned when `~/.vite-plus/bin` was not first in PATH, but on Windows putting bin first actually breaks `vp` due to the trampoline mechanism. The per-tool shim resolution check already provides meaningful diagnostics for shadowed shims.
1 parent b4e091c commit f6f7962

File tree

1 file changed

+9
-20
lines changed
  • crates/vite_global_cli/src/commands/env

1 file changed

+9
-20
lines changed

crates/vite_global_cli/src/commands/env/doctor.rs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -408,29 +408,18 @@ async fn check_path() -> bool {
408408

409409
// Check if bin directory is in PATH
410410
let bin_path = bin_dir.as_path();
411-
let bin_position = paths.iter().position(|p| p == bin_path);
411+
let bin_in_path = paths.iter().any(|p| p == bin_path);
412412

413413
let bin_display = abbreviate_home(&bin_dir.as_path().display().to_string());
414414

415-
match bin_position {
416-
Some(0) => {
417-
print_check(&output::CHECK.green().to_string(), "vp", "first in PATH");
418-
}
419-
Some(pos) => {
420-
print_check(
421-
&output::WARN_SIGN.yellow().to_string(),
422-
"vp",
423-
&format!("in PATH at position {pos}").yellow().to_string(),
424-
);
425-
print_hint("For best results, bin should be first in PATH.");
426-
}
427-
None => {
428-
print_check(&output::CROSS.red().to_string(), "vp", &"not in PATH".red().to_string());
429-
print_hint(&format!("Expected: {bin_display}"));
430-
println!();
431-
print_path_fix(&bin_dir);
432-
return false;
433-
}
415+
if bin_in_path {
416+
print_check(&output::CHECK.green().to_string(), "vp", "in PATH");
417+
} else {
418+
print_check(&output::CROSS.red().to_string(), "vp", &"not in PATH".red().to_string());
419+
print_hint(&format!("Expected: {bin_display}"));
420+
println!();
421+
print_path_fix(&bin_dir);
422+
return false;
434423
}
435424

436425
// Show which tool would be executed for each shim

0 commit comments

Comments
 (0)