diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-01-03 09:45:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-03 14:45:10 +0000 |
commit | 97937a097e8fe52cdefd55bf12a92e19d627aca4 (patch) | |
tree | 42cf3d2f8be398165f275cc9724385a8b0fde361 /cli/tools/jupyter/install.rs | |
parent | a387efa46efc906e410041a46bf4659412dc49b4 (diff) |
fix(jupyter): error message when install fails due to jupyter command not being on PATH (#21767)
We were failing silently in this scenario.
Diffstat (limited to 'cli/tools/jupyter/install.rs')
-rw-r--r-- | cli/tools/jupyter/install.rs | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/cli/tools/jupyter/install.rs b/cli/tools/jupyter/install.rs index ef442e125..3b2079db0 100644 --- a/cli/tools/jupyter/install.rs +++ b/cli/tools/jupyter/install.rs @@ -6,6 +6,7 @@ use deno_core::error::AnyError; use deno_core::serde_json; use deno_core::serde_json::json; use std::env::current_exe; +use std::io::ErrorKind; use std::io::Write; use std::path::Path; use tempfile::TempDir; @@ -76,19 +77,34 @@ pub fn install() -> Result<(), AnyError> { &temp_dir.path().to_string_lossy(), ]) .spawn(); + let mut child = match child_result { + Ok(child) => child, + Err(err) + if matches!( + err.kind(), + ErrorKind::NotFound | ErrorKind::PermissionDenied + ) => + { + return Err(err).context(concat!( + "Failed to spawn 'jupyter' command. Is JupyterLab installed ", + "(https://jupyter.org/install) and available on the PATH?" + )); + } + Err(err) => { + return Err(err).context("Failed to spawn 'jupyter' command."); + } + }; - if let Ok(mut child) = child_result { - let wait_result = child.wait(); - match wait_result { - Ok(status) => { - if !status.success() { - bail!("Failed to install kernelspec, try again."); - } - } - Err(err) => { - bail!("Failed to install kernelspec: {}", err); + let wait_result = child.wait(); + match wait_result { + Ok(status) => { + if !status.success() { + bail!("Failed to install kernelspec, try again."); } } + Err(err) => { + bail!("Failed to install kernelspec: {}", err); + } } let _ = std::fs::remove_dir(temp_dir); |