Improve messaging on install failures and reverts (#118)
This commit is contained in:
parent
fab886cf4d
commit
e2e841ab8e
|
@ -136,12 +136,29 @@ impl CommandExecute for Install {
|
|||
if let Some(expected) = err.expected() {
|
||||
was_expected = true;
|
||||
eprintln!("{}", expected.red())
|
||||
} else {
|
||||
println!(
|
||||
"\
|
||||
{success}\n\
|
||||
To get started using Nix, open a new shell or run `{shell_reminder}`\n\
|
||||
",
|
||||
success = "Nix was installed successfully!".green().bold(),
|
||||
shell_reminder = match std::env::var("SHELL") {
|
||||
Ok(val) if val.contains("fish") =>
|
||||
". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish"
|
||||
.bold(),
|
||||
Ok(_) | Err(_) =>
|
||||
". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh".bold(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if !was_expected {
|
||||
let error = eyre!(err).wrap_err("Install failure");
|
||||
tracing::error!("{:?}", error);
|
||||
};
|
||||
|
||||
eprintln!("{}", "Installation failure, offering to revert...".red());
|
||||
if !interaction::confirm(
|
||||
install_plan
|
||||
.describe_uninstall(explain)
|
||||
|
@ -161,6 +178,15 @@ impl CommandExecute for Install {
|
|||
return Ok(ExitCode::FAILURE);
|
||||
}
|
||||
return Err(e.into());
|
||||
} else {
|
||||
println!(
|
||||
"\
|
||||
{message}\n\
|
||||
",
|
||||
message = "Partial Nix install was uninstalled successfully!"
|
||||
.white()
|
||||
.bold(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if let Some(expected) = err.expected() {
|
||||
|
@ -173,20 +199,6 @@ impl CommandExecute for Install {
|
|||
}
|
||||
}
|
||||
|
||||
println!(
|
||||
"\
|
||||
{success}\n\
|
||||
To get started using Nix, open a new shell or run `{shell_reminder}`\n\
|
||||
",
|
||||
success = "Nix was installed successfully!".green().bold(),
|
||||
shell_reminder = match std::env::var("SHELL") {
|
||||
Ok(val) if val.contains("fish") =>
|
||||
". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish".bold(),
|
||||
Ok(_) | Err(_) =>
|
||||
". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh".bold(),
|
||||
},
|
||||
);
|
||||
|
||||
Ok(ExitCode::SUCCESS)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ impl HasExpectedErrors for HarmonicError {
|
|||
HarmonicError::RecordingReceipt(_, _) => None,
|
||||
HarmonicError::CopyingSelf(_) => None,
|
||||
HarmonicError::SerializingReceipt(_) => None,
|
||||
HarmonicError::Cancelled => None,
|
||||
this @ HarmonicError::Cancelled => Some(Box::new(this)),
|
||||
HarmonicError::SemVer(_) => None,
|
||||
HarmonicError::Planner(planner_error) => planner_error.expected(),
|
||||
HarmonicError::InstallSettings(_) => None,
|
||||
|
|
Loading…
Reference in a new issue