Skip to content

Commit 8712e23

Browse files
committed
install: Always write unix env files out
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
1 parent cea90aa commit 8712e23

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/cli/self_update.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ pub fn install(
338338

339339
let install_res: Result<utils::ExitCode> = (|| {
340340
install_bins()?;
341+
do_write_env_files()?;
341342
if !opts.no_modify_path {
342343
do_add_to_path()?;
343344
}

src/cli/self_update/unix.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ pub fn do_remove_from_path() -> Result<()> {
8181
}
8282

8383
pub fn do_add_to_path() -> Result<()> {
84-
let mut written = vec![];
85-
8684
for sh in shell::get_available_shells() {
8785
let source_cmd = sh.source_string()?;
8886
for rc in sh.update_rcs() {
@@ -92,13 +90,6 @@ pub fn do_add_to_path() -> Result<()> {
9290
path: rc.to_path_buf(),
9391
}
9492
})?;
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-
}
10293
}
10394
}
10495
}
@@ -108,6 +99,21 @@ pub fn do_add_to_path() -> Result<()> {
10899
Ok(())
109100
}
110101

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+
111117
/// Tell the upgrader to replace the rustup bins, then delete
112118
/// itself. Like with uninstallation, on Windows we're going to
113119
/// have to jump through hoops to make everything work right.

src/cli/self_update/windows.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ pub fn do_add_to_path() -> Result<()> {
144144
_apply_new_path(new_path)
145145
}
146146

147+
// Nothing to do for Windows for now
148+
pub fn do_write_env_files() -> Result<()> {
149+
Ok(())
150+
}
151+
147152
fn _apply_new_path(new_path: Option<String>) -> Result<()> {
148153
use std::ptr;
149154
use winapi::shared::minwindef::*;

0 commit comments

Comments
 (0)