diff --git a/crates/vite_global_cli/src/commands/env/doctor.rs b/crates/vite_global_cli/src/commands/env/doctor.rs index c1ace3df55..29aa007158 100644 --- a/crates/vite_global_cli/src/commands/env/doctor.rs +++ b/crates/vite_global_cli/src/commands/env/doctor.rs @@ -503,6 +503,14 @@ fn check_profile_files(vite_plus_home: &str) -> Option { } } + // Also check the default fish conf.d location + let fish_path = format!("{home_dir}/.config/fish/conf.d/vite-plus.fish"); + if let Ok(content) = std::fs::read_to_string(&fish_path) { + if search_strings.iter().any(|s| content.contains(s)) { + return Some(abbreviate_home(&fish_path)); + } + } + None } @@ -888,4 +896,38 @@ mod tests { assert!(result.is_some(), "Should find vite-plus.fish in XDG_CONFIG_HOME"); assert!(result.unwrap().contains("vite-plus.fish")); } + + #[test] + #[serial] + #[cfg(not(windows))] + fn test_check_profile_files_default_fish_config() { + let temp = TempDir::new().unwrap(); + let fake_home = temp.path().join("home"); + std::fs::create_dir_all(&fake_home).unwrap(); + + let fish_dir = fake_home.join(".config/fish/conf.d"); + std::fs::create_dir_all(&fish_dir).unwrap(); + std::fs::write(fish_dir.join("vite-plus.fish"), "source \"$HOME/.vite-plus/env.fish\"\n") + .unwrap(); + + let _guard = ProfileEnvGuard::new(&fake_home, None, None); + + let result = check_profile_files("$HOME/.vite-plus"); + assert!(result.is_some(), "Should find vite-plus.fish in default fish conf.d"); + assert!(result.unwrap().contains("vite-plus.fish")); + } + + #[test] + #[serial] + #[cfg(not(windows))] + fn test_check_profile_files_no_fish_config() { + let temp = TempDir::new().unwrap(); + let fake_home = temp.path().join("home"); + std::fs::create_dir_all(&fake_home).unwrap(); + + let _guard = ProfileEnvGuard::new(&fake_home, None, None); + + let result = check_profile_files("$HOME/.vite-plus"); + assert_eq!(result, None); + } }