Skip to content

Commit cc79a6e

Browse files
committed
Auto merge of #1126 - f-bro:issue-374, r=Diggsey
Add PATH in post-install message when not modifying PATH Fixes #374 Unix: ``` To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. ``` Windows: ``` To get started you need Cargo's bin directory (C:\Users\f-bro\.cargo\bin) in your PATH environment variable. This has not been done automatically. ```
2 parents d1b851f + a2e465c commit cc79a6e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/rustup-cli/self_update.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ macro_rules! post_install_msg_unix {
112112
() => {
113113
r"# Rust is installed now. Great!
114114
115-
To get started you need Cargo's bin directory in your `PATH`
115+
To get started you need Cargo's bin directory ({cargo_home}/bin) in your `PATH`
116116
environment variable. Next time you log in this will be done
117117
automatically.
118118
@@ -125,7 +125,7 @@ macro_rules! post_install_msg_win {
125125
() => {
126126
r"# Rust is installed now. Great!
127127
128-
To get started you need Cargo's bin directory in your `PATH`
128+
To get started you need Cargo's bin directory ({cargo_home}\bin) in your `PATH`
129129
environment variable. Future applications will automatically have the
130130
correct environment, but you may need to restart your current shell.
131131
"
@@ -136,7 +136,7 @@ macro_rules! post_install_msg_unix_no_modify_path {
136136
() => {
137137
r"# Rust is installed now. Great!
138138
139-
To get started you need Cargo's bin directory in your `PATH`
139+
To get started you need Cargo's bin directory ({cargo_home}/bin) in your `PATH`
140140
environment variable.
141141
142142
To configure your current shell run `source {cargo_home}/env`
@@ -148,7 +148,7 @@ macro_rules! post_install_msg_win_no_modify_path {
148148
() => {
149149
r"# Rust is installed now. Great!
150150
151-
To get started you need Cargo's bin directory in your `PATH`
151+
To get started you need Cargo's bin directory ({cargo_home}\bin) in your `PATH`
152152
environment variable. This has not been done automatically.
153153
"
154154
};
@@ -204,7 +204,11 @@ fn canonical_cargo_home() -> Result<String> {
204204

205205
let default_cargo_home = utils::home_dir().unwrap_or(PathBuf::from(".")).join(".cargo");
206206
if default_cargo_home == path {
207-
path_str = String::from("$HOME/.cargo");
207+
if cfg!(unix) {
208+
path_str = String::from("$HOME/.cargo");
209+
} else {
210+
path_str = String::from(r"%USERPROFILE%\.cargo");
211+
}
208212
}
209213

210214
Ok(path_str)
@@ -288,21 +292,22 @@ pub fn install(no_prompt: bool, verbose: bool,
288292

289293
// More helpful advice, skip if -y
290294
if !no_prompt {
295+
let cargo_home = try!(canonical_cargo_home());
291296
let msg = if !opts.no_modify_path {
292297
if cfg!(unix) {
293-
let cargo_home = try!(canonical_cargo_home());
294298
format!(post_install_msg_unix!(),
295299
cargo_home = cargo_home)
296300
} else {
297-
format!(post_install_msg_win!())
301+
format!(post_install_msg_win!(),
302+
cargo_home = cargo_home)
298303
}
299304
} else {
300305
if cfg!(unix) {
301-
let cargo_home = try!(canonical_cargo_home());
302306
format!(post_install_msg_unix_no_modify_path!(),
303307
cargo_home = cargo_home)
304308
} else {
305-
format!(post_install_msg_win_no_modify_path!())
309+
format!(post_install_msg_win_no_modify_path!(),
310+
cargo_home = cargo_home)
306311
}
307312
};
308313
term2::stdout().md(msg);

0 commit comments

Comments
 (0)