diff --git a/cli/src/connection.rs b/cli/src/connection.rs index 3d209d6..2cfa83c 100644 --- a/cli/src/connection.rs +++ b/cli/src/connection.rs @@ -206,12 +206,13 @@ pub fn ensure_daemon(session: &str, headed: bool) -> Result<(), String> { { use std::os::windows::process::CommandExt; - // On Windows, use cmd.exe to run node to ensure proper PATH resolution - // This handles cases where node.exe isn't directly in PATH but node.cmd is + // On Windows, use cmd.exe to run node to ensure proper PATH resolution. + // This handles cases where node.exe isn't directly in PATH but node.cmd is. + // Pass the entire command as a single string to /c to handle paths with spaces. + let cmd_string = format!("node \"{}\"", daemon_path.display()); let mut cmd = Command::new("cmd"); cmd.arg("/c") - .arg("node") - .arg(daemon_path) + .arg(&cmd_string) .env("AGENT_BROWSER_DAEMON", "1") .env("AGENT_BROWSER_SESSION", session); diff --git a/cli/src/install.rs b/cli/src/install.rs index 72fc7f3..f92c1fc 100644 --- a/cli/src/install.rs +++ b/cli/src/install.rs @@ -130,10 +130,11 @@ pub fn run_install(with_deps: bool) { println!("\x1b[36mInstalling Chromium browser...\x1b[0m"); // On Windows, we need to use cmd.exe to run npx because npx is actually npx.cmd - // and Command::new() doesn't resolve .cmd files the way the shell does + // and Command::new() doesn't resolve .cmd files the way the shell does. + // Pass the entire command as a single string to /c to handle paths with spaces. #[cfg(windows)] let status = Command::new("cmd") - .args(["/c", "npx", "playwright", "install", "chromium"]) + .args(["/c", "npx playwright install chromium"]) .status(); #[cfg(not(windows))]