Skip to content

Commit

Permalink
Allow self-update to fail when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
grahnen committed Dec 9, 2024
1 parent 168c370 commit 8ca5de7
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/steps/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,24 @@ pub fn run_elan(ctx: &ExecutionContext) -> Result<()> {
let elan = require("elan")?;

print_separator("elan");
ctx.run_type()
.execute(&elan)
.args(["self", "update"])
.status_checked()?;

let disabled = "self-update is disabled";
let mut exec = ctx.run_type().execute(&elan);
let mut success = true;
if let Err(e) = exec.arg("self").arg("update").status_checked() {
error!("Self-update failed: {e}");
if let Err(e) = exec.output_checked_utf8() {
success = match e.downcast_ref::<TopgradeError>() {
Some(TopgradeError::ProcessFailedWithOutput(_, _, stderr)) => stderr.contains(disabled),
_ => false
}
}
}

if !success {
return Err(eyre!(StepFailed))
}

ctx.run_type().execute(&elan).arg("update").status_checked()
}

Expand Down

0 comments on commit 8ca5de7

Please sign in to comment.