From 0532115ce48d6675d54ba44570b59aa7b033f876 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 31 Dec 2024 16:25:59 +0100 Subject: [PATCH] Improve error message when build.executable doesn't exist (#1303) texlab outputs on standard error: ERROR - Failed to compile document "file:///path/to/test.tex": Unable to run compiler: No such file or directory (os error 2) which is confusing because the actual issue is that "latexmk" was not found. Fix that by adding the program name. This might not be as appropriate for all possible io::Error kinds but it's probably useful for a few of them. --- crates/commands/src/build.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/commands/src/build.rs b/crates/commands/src/build.rs index 23a6e16b..84665f9e 100644 --- a/crates/commands/src/build.rs +++ b/crates/commands/src/build.rs @@ -80,14 +80,16 @@ impl BuildCommand { self.working_dir.display() ); - let mut process = self.spawn_internal()?; + let mut process = self.spawn_internal().map_err(|err| { + BuildError::from(std::io::Error::other(format!("{}: {}", self.program, err))) + })?; track_output(process.stderr.take().unwrap(), sender.clone()); track_output(process.stdout.take().unwrap(), sender); Ok(process) } #[cfg(windows)] - fn spawn_internal(&self) -> Result { + fn spawn_internal(&self) -> std::io::Result { std::process::Command::new(&self.program) .args(self.args.clone()) .stdin(Stdio::null()) @@ -95,11 +97,10 @@ impl BuildCommand { .stderr(Stdio::piped()) .current_dir(&self.working_dir) .spawn() - .map_err(Into::into) } #[cfg(unix)] - fn spawn_internal(&self) -> Result { + fn spawn_internal(&self) -> std::io::Result { use std::os::unix::process::CommandExt; std::process::Command::new(&self.program) .args(self.args.clone()) @@ -109,7 +110,6 @@ impl BuildCommand { .current_dir(&self.working_dir) .process_group(0) .spawn() - .map_err(Into::into) } #[cfg(windows)]