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: run pi via bun instead of relying on node shebang

Louis Beaumont4591f549ec24
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
index ab2bc1675..6f13170eb 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
@@ -36,9 +36,17 @@ fn build_command_for_path(path: &str) -> Command {
}
}
+/// On Unix, pi's shebang is `#!/usr/bin/env node` but screenpipe only bundles
+/// bun. Run `bun <pi_path>` so it works without node installed.
#[cfg(not(windows))]
fn build_command_for_path(path: &str) -> Command {
- Command::new(path)
+ if let Some(bun) = find_bun_executable() {
+ let mut cmd = Command::new(bun);
+ cmd.arg(path);
+ cmd
+ } else {
+ Command::new(path)
+ }
}
/// Async version for tokio::process::Command
@@ -53,9 +61,17 @@ fn build_async_command_for_path(path: &str) -> tokio::process::Command {
}
}
+/// On Unix, pi's shebang is `#!/usr/bin/env node` but screenpipe only bundles
+/// bun. Run `bun <pi_path>` so it works without node installed.
#[cfg(not(windows))]
fn build_async_command_for_path(path: &str) -> tokio::process::Command {
- tokio::process::Command::new(path)
+ 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)
+ }
}
const PI_PACKAGE: &str = "@mariozechner/pi-coding-agent";
diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rs
index fffbc3614..f64740611 100644
--- a/crates/screenpipe-core/src/agents/pi.rs
+++ b/crates/screenpipe-core/src/agents/pi.rs
@@ -468,7 +468,12 @@ pub fn find_pi_executable() -> Option<String> {
None
}
-/// Build an async command, handling .cmd files on Windows.
+/// Build an async command for launching pi.
+///
+/// Pi's shebang is `#!/usr/bin/env node`, but screenpipe only bundles bun
+/// (not node). On Unix we run `bun <pi_path>` so the script executes under
+/// bun's Node-compatible runtime regardless of whether node is installed.
+/// On Windows, .cmd files need `cmd.exe /C`.
fn build_async_command(path: &str) -> tokio::process::Command {
#[cfg(windows)]
{
@@ -482,7 +487,14 @@ fn build_async_command(path: &str) -> tokio::process::Command {
}
#[cfg(not(windows))]
{
- tokio::process::Command::new(path)
+ if let Some(bun) = find_bun_executable() {
+ let mut cmd = tokio::process::Command::new(bun);
+ cmd.arg(path);
+ cmd
+ } else {
+ // Fallback: run pi directly (requires node in PATH)
+ tokio::process::Command::new(path)
+ }
}
}