@@ -61,10 +61,8 @@ mod os {
61
61
pub use crate :: self_update:: windows:: * ;
62
62
}
63
63
64
- pub use os:: {
65
- complete_windows_uninstall, delete_rustup_and_cargo_home, run_update, self_replace,
66
- } ;
67
64
use os:: * ;
65
+ pub use os:: { complete_windows_uninstall, delete_rustup_and_cargo_home, run_update, self_replace} ;
68
66
69
67
pub struct InstallOpts < ' a > {
70
68
pub default_host_triple : Option < String > ,
@@ -323,11 +321,8 @@ pub fn install(no_prompt: bool, verbose: bool, quiet: bool, mut opts: InstallOpt
323
321
quiet,
324
322
) ?;
325
323
326
- if cfg ! ( unix) {
327
- let env_file = utils:: cargo_home ( ) ?. join ( "env" ) ;
328
- let env_str = format ! ( "{}\n " , shell_export_string( ) ?) ;
329
- utils:: write_file ( "env" , & env_file, & env_str) ?;
330
- }
324
+ #[ cfg( unix) ]
325
+ write_env ( ) ?;
331
326
332
327
Ok ( ( ) )
333
328
} ) ( ) ;
@@ -853,69 +848,6 @@ pub fn uninstall(no_prompt: bool) -> Result<()> {
853
848
process:: exit ( 0 ) ;
854
849
}
855
850
856
- /// Decide which rcfiles we're going to update, so we
857
- /// can tell the user before they confirm.
858
- fn get_add_path_methods ( ) -> Vec < PathUpdateMethod > {
859
- if cfg ! ( windows) {
860
- return vec ! [ PathUpdateMethod :: Windows ] ;
861
- }
862
-
863
- let home_dir = utils:: home_dir ( ) . unwrap ( ) ;
864
- let profile = home_dir. join ( ".profile" ) ;
865
- let mut profiles = vec ! [ profile] ;
866
-
867
- if let Ok ( shell) = env:: var ( "SHELL" ) {
868
- if shell. contains ( "zsh" ) {
869
- let var = env:: var_os ( "ZDOTDIR" ) ;
870
- let zdotdir = var. as_deref ( ) . map_or_else ( || home_dir. as_path ( ) , Path :: new) ;
871
- let zprofile = zdotdir. join ( ".zprofile" ) ;
872
- profiles. push ( zprofile) ;
873
- }
874
- }
875
-
876
- let bash_profile = home_dir. join ( ".bash_profile" ) ;
877
- // Only update .bash_profile if it exists because creating .bash_profile
878
- // will cause .profile to not be read
879
- if bash_profile. exists ( ) {
880
- profiles. push ( bash_profile) ;
881
- }
882
-
883
- profiles. into_iter ( ) . map ( PathUpdateMethod :: RcFile ) . collect ( )
884
- }
885
-
886
- fn shell_export_string ( ) -> Result < String > {
887
- let path = format ! ( "{}/bin" , canonical_cargo_home( ) ?) ;
888
- // The path is *prepended* in case there are system-installed
889
- // rustc's that need to be overridden.
890
- Ok ( format ! ( r#"export PATH="{}:$PATH""# , path) )
891
- }
892
-
893
-
894
-
895
- /// Decide which rcfiles we're going to update, so we
896
- /// can tell the user before they confirm.
897
- fn get_remove_path_methods ( ) -> Result < Vec < PathUpdateMethod > > {
898
- if cfg ! ( windows) {
899
- return Ok ( vec ! [ PathUpdateMethod :: Windows ] ) ;
900
- }
901
-
902
- let profile = utils:: home_dir ( ) . map ( |p| p. join ( ".profile" ) ) ;
903
- let bash_profile = utils:: home_dir ( ) . map ( |p| p. join ( ".bash_profile" ) ) ;
904
-
905
- let rcfiles = vec ! [ profile, bash_profile] ;
906
- let existing_rcfiles = rcfiles. into_iter ( ) . filter_map ( |f| f) . filter ( |f| f. exists ( ) ) ;
907
-
908
- let export_str = shell_export_string ( ) ?;
909
- let matching_rcfiles = existing_rcfiles. filter ( |f| {
910
- let file = utils:: read_file ( "rcfile" , f) . unwrap_or_default ( ) ;
911
- let addition = format ! ( "\n {}" , export_str) ;
912
- file. contains ( & addition)
913
- } ) ;
914
-
915
- Ok ( matching_rcfiles. map ( PathUpdateMethod :: RcFile ) . collect ( ) )
916
- }
917
-
918
-
919
851
/// Self update downloads rustup-init to `CARGO_HOME`/bin/rustup-init
920
852
/// and runs it.
921
853
///
@@ -1092,7 +1024,6 @@ pub fn prepare_update() -> Result<Option<PathBuf>> {
1092
1024
Ok ( Some ( setup_path) )
1093
1025
}
1094
1026
1095
-
1096
1027
pub fn cleanup_self_updater ( ) -> Result < ( ) > {
1097
1028
let cargo_home = utils:: cargo_home ( ) ?;
1098
1029
let setup = cargo_home. join ( & format ! ( "bin/rustup-init{}" , EXE_SUFFIX ) ) ;
0 commit comments