File tree Expand file tree Collapse file tree 5 files changed +23
-10
lines changed Expand file tree Collapse file tree 5 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -338,6 +338,7 @@ pub fn install(
338
338
339
339
let install_res: Result < utils:: ExitCode > = ( || {
340
340
install_bins ( ) ?;
341
+ do_write_env_files ( ) ?;
341
342
if !opts. no_modify_path {
342
343
do_add_to_path ( ) ?;
343
344
}
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ case ":${PATH}:" in
5
5
* :" {cargo_bin}" :* )
6
6
;;
7
7
* )
8
- # Prepending path in case a system-installed rustc must be overwritten
8
+ # Prepending path in case a system-installed rustc needs to be overridden
9
9
export PATH=" {cargo_bin}:$PATH "
10
10
;;
11
11
esac
Original file line number Diff line number Diff line change @@ -81,8 +81,6 @@ pub fn do_remove_from_path() -> Result<()> {
81
81
}
82
82
83
83
pub fn do_add_to_path ( ) -> Result < ( ) > {
84
- let mut written = vec ! [ ] ;
85
-
86
84
for sh in shell:: get_available_shells ( ) {
87
85
let source_cmd = sh. source_string ( ) ?;
88
86
for rc in sh. update_rcs ( ) {
@@ -92,13 +90,6 @@ pub fn do_add_to_path() -> Result<()> {
92
90
path : rc. to_path_buf ( ) ,
93
91
}
94
92
} ) ?;
95
- let script = sh. env_script ( ) ;
96
- // Only write scripts once.
97
- // TODO 2021: remove this code if Rustup adds 0 shell scripts.
98
- if !written. contains ( & script) {
99
- script. write ( ) ?;
100
- written. push ( script) ;
101
- }
102
93
}
103
94
}
104
95
}
@@ -108,6 +99,21 @@ pub fn do_add_to_path() -> Result<()> {
108
99
Ok ( ( ) )
109
100
}
110
101
102
+ pub fn do_write_env_files ( ) -> Result < ( ) > {
103
+ let mut written = vec ! [ ] ;
104
+
105
+ for sh in shell:: get_available_shells ( ) {
106
+ let script = sh. env_script ( ) ;
107
+ // Only write each possible script once.
108
+ if !written. contains ( & script) {
109
+ script. write ( ) ?;
110
+ written. push ( script) ;
111
+ }
112
+ }
113
+
114
+ Ok ( ( ) )
115
+ }
116
+
111
117
/// Tell the upgrader to replace the rustup bins, then delete
112
118
/// itself. Like with uninstallation, on Windows we're going to
113
119
/// have to jump through hoops to make everything work right.
Original file line number Diff line number Diff line change @@ -144,6 +144,11 @@ pub fn do_add_to_path() -> Result<()> {
144
144
_apply_new_path ( new_path)
145
145
}
146
146
147
+ // Nothing to do for Windows for now
148
+ pub fn do_write_env_files ( ) -> Result < ( ) > {
149
+ Ok ( ( ) )
150
+ }
151
+
147
152
fn _apply_new_path ( new_path : Option < String > ) -> Result < ( ) > {
148
153
use std:: ptr;
149
154
use winapi:: shared:: minwindef:: * ;
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ Rust is installed now. Great!
110
110
) ;
111
111
if cfg ! ( unix) {
112
112
assert ! ( !config. homedir. join( ".profile" ) . exists( ) ) ;
113
+ assert ! ( config. cargodir. join( "env" ) . exists( ) ) ;
113
114
}
114
115
} ) ;
115
116
}
You can’t perform that action at this time.
0 commit comments