diff --git a/src/rustup-cli/self_update.rs b/src/rustup-cli/self_update.rs index 174b45dc3c..e5b8495350 100644 --- a/src/rustup-cli/self_update.rs +++ b/src/rustup-cli/self_update.rs @@ -1041,15 +1041,13 @@ fn get_add_path_methods() -> Vec { let zprofile = zdotdir.map(|p| p.join(".zprofile")); profiles.push(zprofile); } + } - if shell.contains("bash") { - if let Some(bash_profile) = utils::home_dir().map(|p| p.join(".bash_profile")) { - // Only update .bash_profile if it exists because creating .bash_profile - // will cause .profile to not be read - if bash_profile.exists() { - profiles.push(Some(bash_profile)); - } - } + if let Some(bash_profile) = utils::home_dir().map(|p| p.join(".bash_profile")) { + // Only update .bash_profile if it exists because creating .bash_profile + // will cause .profile to not be read + if bash_profile.exists() { + profiles.push(Some(bash_profile)); } } diff --git a/tests/cli-self-upd.rs b/tests/cli-self-upd.rs index 854e2fdaa7..b572eb3969 100644 --- a/tests/cli-self-upd.rs +++ b/tests/cli-self-upd.rs @@ -323,6 +323,23 @@ fn install_adds_path_to_profile() { install_adds_path_to_rc(".profile"); } +#[test] +#[cfg(unix)] +fn install_adds_path_to_bash_profile() { + install_adds_path_to_rc(".bash_profile"); +} + +#[test] +#[cfg(unix)] +fn install_does_not_add_path_to_bash_profile_that_doesnt_exist() { + setup(&|config| { + let ref rc = config.homedir.join(".bash_profile"); + expect_ok(config, &["rustup-init", "-y"]); + + assert!(!rc.exists()); + }); +} + #[test] #[cfg(unix)] fn install_with_zsh_adds_path_to_zprofile() { @@ -399,10 +416,16 @@ fn uninstall_removes_path_from_rc(rcfile: &str) { #[test] #[cfg(unix)] -fn uninstall_removes_path_from_bashrc() { +fn uninstall_removes_path_from_profile() { uninstall_removes_path_from_rc(".profile"); } +#[test] +#[cfg(unix)] +fn uninstall_removes_path_from_bash_profile() { + uninstall_removes_path_from_rc(".bash_profile"); +} + #[test] #[cfg(unix)] fn uninstall_doesnt_touch_rc_files_that_dont_contain_cargo_home() {