Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: Pi exit code 255 on Windows — run pi.exe through bundled bun

Louis Beaumontc40a939a5a2c
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
index e5e6a185a..4adfbe345 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
@@ -25,12 +25,19 @@ static PI_INSTALL_DONE: AtomicBool = AtomicBool::new(false);
/// On Windows, `.cmd` files cannot be spawned directly with `Command::new()` since
/// Rust 1.77+ (CVE-2024-24576 fix). We must use `cmd.exe /C` to run them.
+/// For `.exe` shims from `bun add -g`, run via bundled bun to ensure the JS
+/// entrypoint resolves correctly (the shim alone fails with exit code 255 on
+/// some Windows machines where bun isn't in PATH).
#[cfg(windows)]
fn build_command_for_path(path: &str) -> Command {
if path.ends_with(".cmd") || path.ends_with(".bat") {
let mut cmd = Command::new("cmd.exe");
cmd.args(["/C", path]);
cmd
+ } else if let Some(bun) = find_bun_executable() {
+ let mut cmd = Command::new(bun);
+ cmd.arg(path);
+ cmd
} else {
Command::new(path)
}
@@ -56,6 +63,10 @@ fn build_async_command_for_path(path: &str) -> tokio::process::Command {
let mut cmd = tokio::process::Command::new("cmd.exe");
cmd.args(["/C", path]);
cmd
+ } else if let Some(bun) = find_bun_executable() {
+ let mut cmd = tokio::process::Command::new(bun);
+ cmd.arg(path);
+ cmd
} else {
tokio::process::Command::new(path)
}