Fix WSL path handling

Resolves #170
This commit is contained in:
Luke Street 2025-08-15 15:34:58 -06:00
parent b21892be31
commit 0f0aaab795

View File

@ -49,6 +49,7 @@ pub fn run_make(config: &BuildConfig, arg: &Utf8UnixPath) -> BuildStatus {
}; };
#[cfg(windows)] #[cfg(windows)]
let mut command = { let mut command = {
use alloc::borrow::Cow;
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt;
let mut command = if config.selected_wsl_distro.is_some() { 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} // Strip distro root prefix \\wsl.localhost\{distro}
let wsl_path_prefix = format!("\\\\wsl.localhost\\{}", distro); let wsl_path_prefix = format!("\\\\wsl.localhost\\{}", distro);
let cwd = match cwd.strip_prefix(wsl_path_prefix) { let cwd = match cwd.strip_prefix(wsl_path_prefix) {
Ok(new_cwd) => Utf8UnixPath::new("/").join(new_cwd.with_unix_encoding()), // Convert to absolute Unix path
Err(_) => cwd.with_unix_encoding(), 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 command
.arg("--cd") .arg("--cd")
.arg(cwd.as_str()) .arg(cwd.as_ref())
.arg("-d") .arg("-d")
.arg(distro) .arg(distro)
.arg("--") .arg("--")