Skip to content

Commit 0f0aaab

Browse files
committed
Fix WSL path handling
Resolves #170
1 parent b21892b commit 0f0aaab

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

objdiff-core/src/build/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub fn run_make(config: &BuildConfig, arg: &Utf8UnixPath) -> BuildStatus {
4949
};
5050
#[cfg(windows)]
5151
let mut command = {
52+
use alloc::borrow::Cow;
5253
use std::os::windows::process::CommandExt;
5354

5455
let mut command = if config.selected_wsl_distro.is_some() {
@@ -60,13 +61,17 @@ pub fn run_make(config: &BuildConfig, arg: &Utf8UnixPath) -> BuildStatus {
6061
// Strip distro root prefix \\wsl.localhost\{distro}
6162
let wsl_path_prefix = format!("\\\\wsl.localhost\\{}", distro);
6263
let cwd = match cwd.strip_prefix(wsl_path_prefix) {
63-
Ok(new_cwd) => Utf8UnixPath::new("/").join(new_cwd.with_unix_encoding()),
64-
Err(_) => cwd.with_unix_encoding(),
64+
// Convert to absolute Unix path
65+
Ok(new_cwd) => Cow::Owned(
66+
Utf8UnixPath::new("/").join(new_cwd.with_unix_encoding()).into_string(),
67+
),
68+
// Otherwise, use the Windows path as is
69+
Err(_) => Cow::Borrowed(cwd.as_str()),
6570
};
6671

6772
command
6873
.arg("--cd")
69-
.arg(cwd.as_str())
74+
.arg(cwd.as_ref())
7075
.arg("-d")
7176
.arg(distro)
7277
.arg("--")

0 commit comments

Comments
 (0)