Skip to content

Commit

Permalink
chore: extra guidance for permission denied case
Browse files Browse the repository at this point in the history
  • Loading branch information
dj8yf0μl committed May 29, 2024
1 parent fc966ca commit 2a07d49
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 15 additions & 5 deletions cargo-near/src/commands/build_command/docker/docker_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(super) fn handle_command_io_error<T>(
Err(io_err) if io_err.kind() == std::io::ErrorKind::NotFound => {
println!();
println!("{}", "`docker` executable isn't available".yellow());
print_installation_links();
print_installation_links(false);
print_non_docker_suggestion();
Err(report)
}
Expand All @@ -37,29 +37,39 @@ pub(super) fn handle_command_io_error<T>(
}
}

fn print_installation_links() {
fn print_installation_links(permission_denied: bool) {
match std::env::consts::OS {
"linux" => {
println!(
"{} {}",
"Please, make sure to follow instructions to correctly install Docker Engine on"
"Please, follow instructions to correctly install Docker Engine on"
.cyan(),
"https://docs.docker.com/engine/install/".magenta()
);
if permission_denied {
println!(
"{} {} {} `{}` {}",
"Please, pay special attention to".cyan(),
"https://docs.docker.com/engine/install/linux-postinstall/".magenta(),
"section regarding your".cyan(),
"permission denied".magenta(),
"problem".cyan(),
);
}
}

"macos" => {
println!(
"{} {}",
"Please, make sure to follow instructions to correctly install Docker Desktop on"
"Please, follow instructions to correctly install Docker Desktop on"
.cyan(),
"https://docs.docker.com/desktop/install/mac-install/".magenta()
);
}
"windows" => {
println!(
"{} {}",
"Please, make sure to follow instructions to correctly install Docker Desktop on"
"Please, follow instructions to correctly install Docker Desktop on"
.cyan(),
"https://docs.docker.com/desktop/install/windows-install/".magenta()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ pub fn check() -> color_eyre::eyre::Result<()> {
println!("{}", stderr.yellow());
if permission_denied(&output.status, stderr)? {
println!("{}", "Permission denied!".cyan());
super::print_installation_links(true);
} else {
super::print_installation_links(false);
}
super::print_installation_links();
super::print_command_status(output.status, docker_cmd);
return Err(color_eyre::eyre::eyre!(ERR_SANITY));
}
Expand Down

0 comments on commit 2a07d49

Please sign in to comment.