From 0f0aaab79543ee7b0d7271cad76e794c4135a11c Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 15 Aug 2025 15:34:58 -0600 Subject: [PATCH] Fix WSL path handling Resolves #170 --- objdiff-core/src/build/mod.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/objdiff-core/src/build/mod.rs b/objdiff-core/src/build/mod.rs index a345887..ed3dfc2 100644 --- a/objdiff-core/src/build/mod.rs +++ b/objdiff-core/src/build/mod.rs @@ -49,6 +49,7 @@ pub fn run_make(config: &BuildConfig, arg: &Utf8UnixPath) -> BuildStatus { }; #[cfg(windows)] let mut command = { + use alloc::borrow::Cow; use std::os::windows::process::CommandExt; let mut command = if config.selected_wsl_distro.is_some() { @@ -60,13 +61,17 @@ pub fn run_make(config: &BuildConfig, arg: &Utf8UnixPath) -> BuildStatus { // Strip distro root prefix \\wsl.localhost\{distro} let wsl_path_prefix = format!("\\\\wsl.localhost\\{}", distro); let cwd = match cwd.strip_prefix(wsl_path_prefix) { - Ok(new_cwd) => Utf8UnixPath::new("/").join(new_cwd.with_unix_encoding()), - Err(_) => cwd.with_unix_encoding(), + // Convert to absolute Unix path + Ok(new_cwd) => Cow::Owned( + Utf8UnixPath::new("/").join(new_cwd.with_unix_encoding()).into_string(), + ), + // Otherwise, use the Windows path as is + Err(_) => Cow::Borrowed(cwd.as_str()), }; command .arg("--cd") - .arg(cwd.as_str()) + .arg(cwd.as_ref()) .arg("-d") .arg(distro) .arg("--")