Simplify get_install_path using cargo_home

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-23 18:36:01 +10:00
parent 79476e490b
commit 5620810c55
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -187,20 +187,9 @@ pub fn get_install_path<P: AsRef<Path>>(install_path: Option<P>) -> (Option<Path
return (Some(b.join("bin")), true); return (Some(b.join("bin")), true);
} }
if let Ok(p) = std::env::var("CARGO_HOME") { if let Ok(p) = cargo_home() {
debug!("using CARGO_HOME ({p})"); debug!("using ({}) as cargo home", p.display());
let b = PathBuf::from(p); return (Some(p.into()), false);
return (Some(b.join("bin")), false);
}
// Standard $HOME/.cargo/bin
if let Some(d) = dirs::home_dir() {
let d = d.join(".cargo/bin");
if d.exists() {
debug!("using $HOME/.cargo/bin");
return (Some(d), false);
}
} }
// Local executable dir if no cargo is found // Local executable dir if no cargo is found