Better error message for uv run failures (#3691)

Attach path context to `uv run` failures since those function calls are
not covered by `fs_err`.
This commit is contained in:
konsti 2024-05-21 13:24:18 +02:00 committed by GitHub
parent 2c4088a518
commit d326e1f5e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,7 @@
use std::ffi::OsString; use std::ffi::OsString;
use std::path::PathBuf; use std::path::PathBuf;
use anyhow::Result; use anyhow::{Context, Result};
use itertools::Itertools; use itertools::Itertools;
use tempfile::tempdir_in; use tempfile::tempdir_in;
use tokio::process::Command; use tokio::process::Command;
@ -166,8 +166,10 @@ pub(crate) async fn run(
"Running `{command}{space}{}`", "Running `{command}{space}{}`",
args.iter().map(|arg| arg.to_string_lossy()).join(" ") args.iter().map(|arg| arg.to_string_lossy()).join(" ")
); );
let mut handle = process.spawn()?; let mut handle = process
let status = handle.wait().await?; .spawn()
.with_context(|| format!("Failed to spawn: `{command}`"))?;
let status = handle.wait().await.context("Child process disappeared")?;
// Exit based on the result of the command // Exit based on the result of the command
// TODO(zanieb): Do we want to exit with the code of the child process? Probably. // TODO(zanieb): Do we want to exit with the code of the child process? Probably.