diff --git a/src/backend/src/lib.rs b/src/backend/src/lib.rs index d981911..2202301 100644 --- a/src/backend/src/lib.rs +++ b/src/backend/src/lib.rs @@ -185,12 +185,18 @@ // Note: Tauri's sidecar() handles the library path (DLLs) if they are in the same folder // as the sidecar binary in the App bundle. - // However, on Windows, adding the resource dir to PATH is safer for DLL discovery. + // However, on Windows, setting the current_dir to the resource folder and + // adding it to PATH is the most robust way to ensure DLLs are found. let res_dir = app_handle.path().resource_dir().unwrap_or_default(); let old_path = std::env::var("PATH").unwrap_or_default(); let new_path = format!("{};{}", res_dir.display(), old_path); - let sidecar = sidecar.args(args).env("PATH", new_path); + let mut sidecar = sidecar.args(args).env("PATH", new_path); + + // Set current directory to the resource folder so the sidecar can find DLLs "locally" + if res_dir.exists() { + sidecar = sidecar.current_dir(res_dir); + } let (mut rx, _child) = match sidecar.spawn() { Ok(res) => res,