fix(cli): split IDE and shell profile checks in vp env doctor#961
Open
jong-kyung wants to merge 3 commits intovoidzero-dev:mainfrom
Open
fix(cli): split IDE and shell profile checks in vp env doctor#961jong-kyung wants to merge 3 commits intovoidzero-dev:mainfrom
vp env doctor#961jong-kyung wants to merge 3 commits intovoidzero-dev:mainfrom
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
Contributor
There was a problem hiding this comment.
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
EnvSourcingStatusclassification 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_filesadds an XDG_CONFIG_HOME fallback, but it only checksfish/conf.d/vite-plus.fish. If a user setsXDG_CONFIG_HOMEand sources Vite+ fromfish/config.fish(which is also under XDG), the base loop will look under$HOME/.config/...and the fallback won’t catch it, sodoctorcan incorrectly reportNotFound/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), | ||
| ]; |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EnvSourcingStatus(IdeFound/ShellOnly/NotFound) to replace the booleancheck_ide_integration()return.zshenv,.profile) first, then fall back to all shell profiles (.bashrc,.zshrc,.bash_profile, fish configs)env.fishpattern matching viais_fishflagcheck_profile_files()to accept profile list as argument for reuseThis avoids the false positives that caused #878 to be rejected (marking
.bashrcas IDE-OK) while eliminating the false negatives from #881 (ignoring shell-only sourcing entirely).Closes #881