Improved error message when self-update cannot find the current binary

This commit is contained in:
Mick Grove 2025-09-02 13:59:01 -07:00
commit 23102f4b59
2 changed files with 26 additions and 10 deletions

View file

@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
## [Unreleased]
- Improved error message when self-update cannot find the current binary.
## [1.47.0]
- MongoDB validator now validates `mongodb+srv://` URIs with a fast timeout instead of skipping them
- Improved rules: github oauth2, diffbot, mailchimp, aws

View file

@ -129,16 +129,29 @@ pub fn check_for_update(global_args: &GlobalArgs, base_url: Option<&str>) -> Opt
.apply_to(&format!("Updated to version {}", status.version()))
),
Err(e) => match e {
UpdError::Io(ref io_err) if io_err.kind() == ErrorKind::PermissionDenied => {
warn!(
"{}",
styles.style_finding_active_heading.apply_to(
"Cannot replace the current binary - permission denied.\n\
If you installed via a package manager, run its upgrade command.\n\
Otherwise reinstall to a user-writable directory or re-run with sudo."
)
);
}
UpdError::Io(ref io_err) => match io_err.kind() {
ErrorKind::PermissionDenied => {
warn!(
"{}",
styles.style_finding_active_heading.apply_to(
"Cannot replace the current binary - permission denied.\n\
If you installed via a package manager, run its upgrade command.\n\
Otherwise reinstall to a user-writable directory or re-run with sudo."
)
);
}
ErrorKind::NotFound => {
warn!(
"{}",
styles.style_finding_active_heading.apply_to(
"Cannot replace the current binary - file not found.\n\
If you installed via a package manager, run its upgrade command.\n\
Otherwise reinstall to a user-writable directory."
)
);
}
_ => error!("Failed to update: {e}"),
},
_ => error!("Failed to update: {e}"),
},
}