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 {