From 22dd1b90c4eb5671decd458cc70935898f9ccf0d Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 9 Nov 2021 11:06:45 +0100 Subject: fix(cli/upgrade): nice error when unzip is missing (#12693) Previously just a generic "error: No such file or directory (os error 2)" was printed. Now "`unzip` was not found on your PATH, please install `unzip`" will be printed. --- cli/tools/upgrade.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'cli') diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index 752929b94..6de8ba932 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -2,7 +2,8 @@ //! This module provides feature to upgrade deno executable -use deno_core::error::{bail, AnyError}; +use deno_core::error::bail; +use deno_core::error::AnyError; use deno_core::futures::StreamExt; use deno_runtime::deno_fetch::reqwest; use deno_runtime::deno_fetch::reqwest::Client; @@ -262,7 +263,17 @@ pub fn unpack( Command::new("unzip") .current_dir(&temp_dir) .arg(archive_path) - .spawn()? + .spawn() + .map_err(|err| { + if err.kind() == std::io::ErrorKind::NotFound { + std::io::Error::new( + std::io::ErrorKind::NotFound, + "`unzip` was not found on your PATH, please install `unzip`", + ) + } else { + err + } + })? .wait()? } ext => panic!("Unsupported archive type: '{}'", ext), -- cgit v1.2.3