Skip to content

Commit 4d7ed09

Browse files
committed
fix(env): show system Node.js info in doctor when system-first mode is active
Previously, `vp env doctor` always showed managed version resolution (from .node-version, engines.node, etc.) even in system-first mode. Now the Version Resolution section shows: - Source: "system PATH" - Version: actual system node version (from `node --version`) - Node binary: system node path (e.g., /usr/local/bin/node)
1 parent 297597e commit 4d7ed09

1 file changed

Lines changed: 41 additions & 7 deletions

File tree

  • crates/vite_global_cli/src/commands/env

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

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub async fn execute(cwd: AbsolutePathBuf) -> Result<ExitStatus, Error> {
114114

115115
// Section: Configuration
116116
print_section("Configuration");
117-
check_shim_mode().await;
117+
let shim_mode = check_shim_mode().await;
118118

119119
// Check env sourcing: IDE-relevant profiles first, then all shell profiles
120120
#[cfg(not(windows))]
@@ -128,7 +128,7 @@ pub async fn execute(cwd: AbsolutePathBuf) -> Result<ExitStatus, Error> {
128128

129129
// Section: Version Resolution
130130
print_section("Version Resolution");
131-
check_current_resolution(&cwd).await;
131+
check_current_resolution(&cwd, shim_mode).await;
132132

133133
// Section: Conflicts (conditional)
134134
check_conflicts();
@@ -247,17 +247,17 @@ fn shim_filename(tool: &str) -> String {
247247
}
248248
}
249249

250-
/// Check and display shim mode.
251-
async fn check_shim_mode() {
250+
/// Check and display shim mode. Returns the current mode for use by other checks.
251+
async fn check_shim_mode() -> ShimMode {
252252
let config = match load_config().await {
253253
Ok(c) => c,
254254
Err(e) => {
255255
print_check(
256256
&output::WARN_SIGN.yellow().to_string(),
257-
"Shim mode",
257+
"Node.js mode",
258258
&format!("config error: {e}").yellow().to_string(),
259259
);
260-
return;
260+
return ShimMode::default();
261261
}
262262
};
263263

@@ -284,6 +284,8 @@ async fn check_shim_mode() {
284284
}
285285
}
286286
}
287+
288+
config.shim_mode
287289
}
288290

289291
/// Check profile files for env sourcing and classify where it was found.
@@ -583,9 +585,31 @@ fn print_ide_setup_guidance(bin_dir: &vite_path::AbsolutePath) {
583585
}
584586

585587
/// Check current directory version resolution.
586-
async fn check_current_resolution(cwd: &AbsolutePathBuf) {
588+
async fn check_current_resolution(cwd: &AbsolutePathBuf, shim_mode: ShimMode) {
587589
print_check(" ", "Directory", &cwd.as_path().display().to_string());
588590

591+
// In system-first mode, show system Node.js version instead of managed resolution
592+
if shim_mode == ShimMode::SystemFirst {
593+
if let Some(system_node) = shim::find_system_tool("node") {
594+
let version = get_node_version(&system_node).await;
595+
print_check(" ", "Source", "system PATH");
596+
print_check(" ", "Version", &version.bright_green().to_string());
597+
print_check(
598+
&output::CHECK.green().to_string(),
599+
"Node binary",
600+
&system_node.as_path().display().to_string(),
601+
);
602+
} else {
603+
print_check(
604+
&output::WARN_SIGN.yellow().to_string(),
605+
"System Node.js",
606+
&"not found in PATH".yellow().to_string(),
607+
);
608+
print_hint("Install Node.js or run 'vp env on' to use managed Node.js.");
609+
}
610+
return;
611+
}
612+
589613
match resolve_version(cwd).await {
590614
Ok(resolution) => {
591615
let source_display = resolution
@@ -628,6 +652,16 @@ async fn check_current_resolution(cwd: &AbsolutePathBuf) {
628652
}
629653
}
630654

655+
/// Get the version string from a Node.js binary.
656+
async fn get_node_version(node_path: &vite_path::AbsolutePath) -> String {
657+
match tokio::process::Command::new(node_path.as_path()).arg("--version").output().await {
658+
Ok(output) if output.status.success() => {
659+
String::from_utf8_lossy(&output.stdout).trim().to_string()
660+
}
661+
_ => "unknown".to_string(),
662+
}
663+
}
664+
631665
/// Check for conflicts with other version managers.
632666
fn check_conflicts() {
633667
let mut conflicts = Vec::new();

0 commit comments

Comments
 (0)