Skip to content

Commit 4567250

Browse files
Merge pull request #990 from dsully/main
Don't update the user's shell config files if VOLTA_HOME and PATH already contains what we need.
2 parents 2b45680 + 6e2129c commit 4567250

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/command/setup.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ mod os {
4343
let home = volta_home()?;
4444
let formatted_home = format_home(home.root());
4545

46+
// Don't update the user's shell config files if VOLTA_HOME and PATH already contain what we need.
47+
let home_in_path = match env::var_os("PATH") {
48+
Some(paths) => env::split_paths(&paths).find(|p| p == home.shim_dir()),
49+
None => None,
50+
};
51+
52+
if env::var_os("VOLTA_HOME").is_some() && home_in_path.is_some() {
53+
debug!(
54+
"Skipping dot-file modification as VOLTA_HOME is set, and included in the PATH."
55+
);
56+
return Ok(());
57+
}
58+
4659
debug!("Searching for profiles to update");
4760
let profiles = determine_profiles()?;
4861

0 commit comments

Comments
 (0)