diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index e3823980af..b839665685 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -215,24 +215,33 @@ but will not be added automatically." }; } +#[cfg(not(windows))] +macro_rules! post_install_msg_unix_source_env { + () => { + r#"To configure your current shell, you need to source +the corresponding `env` file under {cargo_home}. + +This is usually done by running one of the following: + source "{cargo_home}/env" # For bash/zsh + . "{cargo_home}/env" # For ash/dash/pdksh (note the leading DOT) + source "{cargo_home}/env.fish" # For fish +"# + }; +} + #[cfg(not(windows))] macro_rules! post_install_msg_unix { () => { - r#"# Rust is installed now. Great! + concat!( + r"# Rust is installed now. Great! To get started you may need to restart your current shell. This would reload your `PATH` environment variable to include Cargo's bin directory ({cargo_home}/bin). -To configure your current shell, you need to source -the `env` file ({cargo_home}/env). - -This is usually done by running: - source "{cargo_home}/env" - -The `source` command above might need to be replaced with `.` -on shells like `ash`, `dash` and `pdksh`. -"# +", + post_install_msg_unix_source_env!(), + ) }; } @@ -252,20 +261,15 @@ Cargo's bin directory ({cargo_home}\\bin). #[cfg(not(windows))] macro_rules! post_install_msg_unix_no_modify_path { () => { - r#"# Rust is installed now. Great! + concat!( + r"# Rust is installed now. Great! To get started you need Cargo's bin directory ({cargo_home}/bin) in your `PATH` environment variable. This has not been done automatically. -To configure your current shell, you need to source -the `env` file ({cargo_home}/env). - -This is usually done by running: - source "{cargo_home}/env" - -The `source` command above might need to be replaced with `.` -on shells like `ash`, `dash` and `pdksh`. -"# +", + post_install_msg_unix_source_env!(), + ) }; } diff --git a/src/cli/self_update/shell.rs b/src/cli/self_update/shell.rs index 4983a5dd4a..fdd220e235 100644 --- a/src/cli/self_update/shell.rs +++ b/src/cli/self_update/shell.rs @@ -212,7 +212,7 @@ impl UnixShell for Fish { fn does_exist(&self) -> bool { // fish has to either be the shell or be callable for fish setup. matches!(process().var("SHELL"), Ok(sh) if sh.contains("fish")) - || matches!(utils::find_cmd(&["fish"]), Some(_)) + || utils::find_cmd(&["fish"]).is_some() } // > "$XDG_CONFIG_HOME/fish/conf.d" (or "~/.config/fish/conf.d" if that variable is unset) for the user