30
30
//! Deleting the running binary during uninstall is tricky
31
31
//! and racy on Windows.
32
32
33
- use crate :: common:: { self , Confirm } ;
33
+ use crate :: common:: { self , ignorable_error , Confirm } ;
34
34
use crate :: errors:: * ;
35
35
use crate :: markdown:: md;
36
36
use crate :: term2;
@@ -235,7 +235,7 @@ fn canonical_cargo_home() -> Result<String> {
235
235
/// `CARGO_HOME`/bin, hard-linking the various Rust tools to it,
236
236
/// and adding `CARGO_HOME`/bin to PATH.
237
237
pub fn install ( no_prompt : bool , verbose : bool , quiet : bool , mut opts : InstallOpts ) -> Result < ( ) > {
238
- do_pre_install_sanity_checks ( ) ?;
238
+ do_pre_install_sanity_checks ( no_prompt ) ?;
239
239
do_pre_install_options_sanity_checks ( & opts) ?;
240
240
check_existence_of_rustc_or_cargo_in_path ( no_prompt) ?;
241
241
#[ cfg( unix) ]
@@ -378,8 +378,8 @@ fn check_existence_of_rustc_or_cargo_in_path(no_prompt: bool) -> Result<()> {
378
378
// Only the test runner should set this
379
379
let skip_check = env:: var_os ( "RUSTUP_INIT_SKIP_PATH_CHECK" ) ;
380
380
381
- // Ignore this check if called with no prompt (-y) or if the environment variable is set
382
- if no_prompt || skip_check == Some ( "yes" . into ( ) ) {
381
+ // Skip this if the environment variable is set
382
+ if skip_check == Some ( "yes" . into ( ) ) {
383
383
return Ok ( ( ) ) ;
384
384
}
385
385
@@ -390,13 +390,12 @@ fn check_existence_of_rustc_or_cargo_in_path(no_prompt: bool) -> Result<()> {
390
390
err ! ( "Otherwise you may have confusion unless you are careful with your PATH" ) ;
391
391
err ! ( "If you are sure that you want both rustup and your already installed Rust" ) ;
392
392
err ! ( "then please restart the installation and pass `-y' to bypass this check." ) ;
393
- Err ( "cannot install while Rust is installed" . into ( ) )
394
- } else {
395
- Ok ( ( ) )
393
+ ignorable_error ( "cannot install while Rust is installed" . into ( ) , no_prompt) ?;
396
394
}
395
+ Ok ( ( ) )
397
396
}
398
397
399
- fn do_pre_install_sanity_checks ( ) -> Result < ( ) > {
398
+ fn do_pre_install_sanity_checks ( no_prompt : bool ) -> Result < ( ) > {
400
399
let rustc_manifest_path = PathBuf :: from ( "/usr/local/lib/rustlib/manifest-rustc" ) ;
401
400
let uninstaller_path = PathBuf :: from ( "/usr/local/lib/rustlib/uninstall.sh" ) ;
402
401
let rustup_sh_path = utils:: home_dir ( ) . unwrap ( ) . join ( ".rustup" ) ;
@@ -412,7 +411,7 @@ fn do_pre_install_sanity_checks() -> Result<()> {
412
411
"run `{}` as root to uninstall Rust" ,
413
412
uninstaller_path. display( )
414
413
) ;
415
- // return Err ("cannot install while Rust is installed".into()) ;
414
+ ignorable_error ( "cannot install while Rust is installed" . into ( ) , no_prompt ) ? ;
416
415
}
417
416
418
417
if rustup_sh_exists {
@@ -422,7 +421,10 @@ fn do_pre_install_sanity_checks() -> Result<()> {
422
421
warn ! ( "or, if you already have rustup installed, you can run" ) ;
423
422
warn ! ( "`rustup self update` and `rustup toolchain list` to upgrade" ) ;
424
423
warn ! ( "your directory structure" ) ;
425
- return Err ( "cannot install while rustup.sh is installed" . into ( ) ) ;
424
+ ignorable_error (
425
+ "cannot install while rustup.sh is installed" . into ( ) ,
426
+ no_prompt,
427
+ ) ?;
426
428
}
427
429
428
430
Ok ( ( ) )
0 commit comments