diff --git a/src/command/setup.rs b/src/command/setup.rs index 96b8a62d0..994e1d76e 100644 --- a/src/command/setup.rs +++ b/src/command/setup.rs @@ -43,6 +43,19 @@ mod os { let home = volta_home()?; let formatted_home = format_home(home.root()); + // Don't update the user's shell config files if VOLTA_HOME and PATH already contain what we need. + let home_in_path = match env::var_os("PATH") { + Some(paths) => env::split_paths(&paths).find(|p| p == home.shim_dir()), + None => None, + }; + + if env::var_os("VOLTA_HOME").is_some() && home_in_path.is_some() { + debug!( + "Skipping dot-file modification as VOLTA_HOME is set, and included in the PATH." + ); + return Ok(()); + } + debug!("Searching for profiles to update"); let profiles = determine_profiles()?;