Skip to content

fix(cli): split IDE and shell profile checks in vp env doctor#961

Open
jong-kyung wants to merge 3 commits intovoidzero-dev:mainfrom
hamsurang:fix/env-doctor-shell-profile-check
Open

fix(cli): split IDE and shell profile checks in vp env doctor#961
jong-kyung wants to merge 3 commits intovoidzero-dev:mainfrom
hamsurang:fix/env-doctor-shell-profile-check

Conversation

@jong-kyung
Copy link

Summary

  • Introduce tri-state EnvSourcingStatus (IdeFound / ShellOnly / NotFound) to replace the boolean check_ide_integration() return
  • Check IDE-visible profiles (.zshenv, .profile) first, then fall back to all shell profiles (.bashrc, .zshrc, .bash_profile, fish configs)
  • Add proper fish shell support with env.fish pattern matching via is_fish flag
  • Parameterize check_profile_files() to accept profile list as argument for reuse

This avoids the false positives that caused #878 to be rejected (marking .bashrc as IDE-OK) while eliminating the false negatives from #881 (ignoring shell-only sourcing entirely).

Closes #881

@netlify
Copy link

netlify bot commented Mar 16, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit df86478
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69b807a2c0cef2000924de10

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the vp env doctor diagnostics to better detect where Vite+ env sourcing is configured, distinguishing IDE-relevant profiles from interactive shell-only profiles (including fish).

Changes:

  • Added OS-specific IDE profile lists and a broader shell profile list (with fish-aware detection).
  • Replaced the previous IDE integration boolean check with a richer EnvSourcingStatus classification and adjusted IDE guidance triggering.
  • Extended/updated unit tests for profile-file detection, including fish and absolute-path sourcing cases.
Comments suppressed due to low confidence (1)

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

  • check_profile_files adds an XDG_CONFIG_HOME fallback, but it only checks fish/conf.d/vite-plus.fish. If a user sets XDG_CONFIG_HOME and sources Vite+ from fish/config.fish (which is also under XDG), the base loop will look under $HOME/.config/... and the fallback won’t catch it, so doctor can incorrectly report NotFound/show IDE guidance. Consider extending the XDG fallback to also check $XDG_CONFIG_HOME/fish/config.fish (and/or generalize path expansion so fish paths aren’t hardcoded to $HOME/.config).
    // If XDG_CONFIG_HOME is set and differs from default, also check fish conf.d
    if let Ok(xdg_config) = std::env::var("XDG_CONFIG_HOME") {
        let default_config = format!("{home_dir}/.config");
        if !xdg_config.is_empty() && xdg_config != default_config {
            let fish_suffix = "/env.fish";
            let mut search_strings = vec![format!("{vite_plus_home}{fish_suffix}")];
            if let Some(suffix) = vite_plus_home.strip_prefix("$HOME") {
                search_strings.push(format!("{home_dir}{suffix}{fish_suffix}"));
            }

            let path = format!("{xdg_config}/fish/conf.d/vite-plus.fish");
            if let Ok(content) = std::fs::read_to_string(&path) {
                if search_strings.iter().any(|s| content.contains(s)) {
                    return Some(abbreviate_home(&path));
                }
            }
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +31 to +44
/// All shell profile files that interactive terminal sessions may source.
/// This matches the files that `install.sh` writes to and `vp implode` cleans.
/// The bool flag indicates whether the file uses fish-style sourcing (`env.fish`
/// instead of `env`).
#[cfg(not(windows))]
const ALL_SHELL_PROFILES: &[(&str, bool)] = &[
(".zshenv", false),
(".zshrc", false),
(".bash_profile", false),
(".bashrc", false),
(".profile", false),
(".config/fish/config.fish", true),
(".config/fish/conf.d/vite-plus.fish", true),
];
@jong-kyung jong-kyung marked this pull request as draft March 16, 2026 13:02
@jong-kyung jong-kyung marked this pull request as ready for review March 16, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(env): vp env doctor misses most shell profiles when checking IDE integration

2 participants