From 22e43741f30e46c79e38a3b70217f0225902c298 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Thu, 17 Sep 2026 18:50:09 +0200 Subject: [PATCH] build: make build_source_package(None) default to the current directory None mapped to Path::new("."), whose parent is the empty string: the output-directory derivation then always failed with 'cannot determine output directory', making the documented Option default a guaranteed-failure trap. Resolve None to the process's absolute current working directory instead. --- src/build/mod.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/build/mod.rs b/src/build/mod.rs index 0938389..2946c9b 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -72,11 +72,19 @@ pub fn build_source_package( cwd: Option<&Path>, ui: Option>, ) -> Result<(), Box> { - let cwd = cwd.unwrap_or_else(|| Path::new(".")); - let output = match run_source_build(cwd, &SourceBuildOptions::default(), ui.clone()) { + // Default to the process's current working directory, resolved to an + // absolute path: the output directory is derived from `cwd.parent()` + // downstream, which only yields a real directory for an absolute `cwd` + // (the parent of "." is the empty path). + let cwd = match cwd { + Some(p) => p.to_path_buf(), + None => std::env::current_dir() + .map_err(|e| format!("cannot determine the current working directory: {e}"))?, + }; + let output = match run_source_build(&cwd, &SourceBuildOptions::default(), ui.clone()) { Ok(output) => output, Err(e) if e.downcast_ref::().is_some() => { - return retry_after_revendor(cwd, ui, e); + return retry_after_revendor(&cwd, ui, e); } Err(e) => { if let Some(u) = &ui {