Skip to content

Commit

Permalink
Silence error that occurs if nightly toolchain is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniusnaumann committed Aug 4, 2024
1 parent 64a73ba commit a5ba6a0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/commands/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,11 @@ fn check_nightly_installed(targets: &[Target]) -> Vec<&'static str> {
return vec![];
}

// TODO: Check if the correct nightly toolchain itself is installed
let mut rustup = command("rustup component list --toolchain nightly");
rustup.stdout(Stdio::piped());
// HACK: Silence error that toolchain is not installed
rustup.stderr(Stdio::null());

let output = rustup
.execute_output()
Expand All @@ -334,7 +337,7 @@ fn check_nightly_installed(targets: &[Target]) -> Vec<&'static str> {
{
vec![]
} else {
vec!["rust-src"]
vec!["rust-src (nightly)"]
}
}

Expand Down Expand Up @@ -399,6 +402,21 @@ fn install_nightly_src(silent: bool) -> Result<()> {
.then(|| MainSpinner::with_message("Installing Toolchains...".to_owned()));
multi.add(&spinner);
spinner.start();

let mut install = command("rustup toolchain install nightly");
install.stdin(Stdio::null());

let step = silent.not().then(|| CommandSpinner::with_command(&install));
multi.add(&step);
step.start();

// TODO: make this a separate function and show error spinner on fail
install
.execute()
.map_err(|e| format!("Error while installing rust-src on nightly: \n\t{e}"))?;

step.finish();

let mut install = command("rustup component add rust-src --toolchain nightly");
install.stdin(Stdio::null());

Expand Down

0 comments on commit a5ba6a0

Please sign in to comment.