Skip to content

Commit

Permalink
Improve error message when build.executable doesn't exist (#1303)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
krobelus authored Dec 31, 2024
1 parent 2f79d32 commit 0532115
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/commands/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,27 @@ 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<Child, BuildError> {
fn spawn_internal(&self) -> std::io::Result<Child> {
std::process::Command::new(&self.program)
.args(self.args.clone())
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.current_dir(&self.working_dir)
.spawn()
.map_err(Into::into)
}

#[cfg(unix)]
fn spawn_internal(&self) -> Result<Child, BuildError> {
fn spawn_internal(&self) -> std::io::Result<Child> {
use std::os::unix::process::CommandExt;
std::process::Command::new(&self.program)
.args(self.args.clone())
Expand All @@ -109,7 +110,6 @@ impl BuildCommand {
.current_dir(&self.working_dir)
.process_group(0)
.spawn()
.map_err(Into::into)
}

#[cfg(windows)]
Expand Down

0 comments on commit 0532115

Please sign in to comment.