mirror of
https://github.com/denoland/deno
synced 2024-11-05 18:45:24 +00:00
fix(jupyter): error message when install fails due to jupyter command not being on PATH (#21767)
We were failing silently in this scenario.
This commit is contained in:
parent
a387efa46e
commit
97937a097e
4 changed files with 42 additions and 11 deletions
8
cli/tests/integration/jupyter_tests.rs
Normal file
8
cli/tests/integration/jupyter_tests.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
itest!(jupyter_install_command_not_exists {
|
||||
args: "jupyter --unstable --install",
|
||||
output: "jupyter/install_command_not_exists.out",
|
||||
envs: vec![("PATH".to_string(), "".to_string())],
|
||||
exit_code: 1,
|
||||
});
|
|
@ -121,7 +121,10 @@ mod inspector;
|
|||
mod install;
|
||||
#[path = "js_unit_tests.rs"]
|
||||
mod js_unit_tests;
|
||||
mod jsr_tests;
|
||||
#[path = "jsr_tests.rs"]
|
||||
mod jsr;
|
||||
#[path = "jupyter_tests.rs"]
|
||||
mod jupyter;
|
||||
#[path = "lint_tests.rs"]
|
||||
mod lint;
|
||||
#[path = "lsp_tests.rs"]
|
||||
|
|
4
cli/tests/testdata/jupyter/install_command_not_exists.out
vendored
Normal file
4
cli/tests/testdata/jupyter/install_command_not_exists.out
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
error: Failed to spawn 'jupyter' command. Is JupyterLab installed (https://jupyter.org/install) and available on the PATH?
|
||||
|
||||
Caused by:
|
||||
[WILDCARD]
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue