From d326e1f5e94ee677ecdaf0079e84d2ea71418d29 Mon Sep 17 00:00:00 2001 From: konsti Date: Tue, 21 May 2024 13:24:18 +0200 Subject: [PATCH] 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`. --- crates/uv/src/commands/project/run.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index 3d54b10a2..90d60080b 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -1,7 +1,7 @@ use std::ffi::OsString; use std::path::PathBuf; -use anyhow::Result; +use anyhow::{Context, Result}; use itertools::Itertools; use tempfile::tempdir_in; use tokio::process::Command; @@ -166,8 +166,10 @@ pub(crate) async fn run( "Running `{command}{space}{}`", args.iter().map(|arg| arg.to_string_lossy()).join(" ") ); - let mut handle = process.spawn()?; - let status = handle.wait().await?; + let mut handle = process + .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 // TODO(zanieb): Do we want to exit with the code of the child process? Probably.