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

[codex] fix AppImage bun env for Pi install (#4712)

Louis Beaumont387de7246667
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
index 68cb29246..b15ed5d32 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
@@ -875,9 +875,9 @@ fn apply_no_window(_cmd: &mut Command) {
fn bun_command(bun: &str) -> Command {
let mut cmd = Command::new(bun);
- // Single source of truth in screenpipe-core: only strips LD_LIBRARY_PATH
- // when running inside an AppImage (APPDIR set), so bun doesn't load the
- // bundle's glibc/libstdc++ and crash.
+ // Single source of truth in screenpipe-core: on Linux, bun subprocesses
+ // must not inherit the app's LD_LIBRARY_PATH, or bundled runtimes like
+ // AppImage can make bun crash before it prints diagnostics.
screenpipe_core::agents::pi::scrub_bun_runtime_env(&mut cmd);
cmd
}
diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rs
index f2d4676a4..59f0eb14d 100644
--- a/crates/screenpipe-core/src/agents/pi.rs
+++ b/crates/screenpipe-core/src/agents/pi.rs
@@ -2247,12 +2247,14 @@ pub fn bun_version_string(bun: &str) -> String {
}
}
-/// Inside an AppImage, AppRun exports `LD_LIBRARY_PATH` pointing at the bundle's
-/// libs. bun is a self-contained baseline binary and must not inherit it, or it
-/// loads the bundled glibc/libstdc++ and crashes (SIGSEGV/SIGILL). Only scrub it
-/// in that environment so a normal Linux install keeps any user-set value.
+/// On Linux, bun is a self-contained baseline binary and should not inherit the
+/// parent process' `LD_LIBRARY_PATH`. In AppImage launches that path points at
+/// the bundle's glibc/libstdc++ and bun can crash before it prints anything
+/// (observed as SIGSEGV/SIGILL during AppImage smoke). Scrubbing unconditionally
+/// on Linux avoids relying on AppImage-specific env markers that may not survive
+/// every launcher path.
fn should_scrub_bun_runtime_env() -> bool {
- cfg!(target_os = "linux") && std::env::var_os("APPDIR").is_some()
+ cfg!(target_os = "linux")
}
/// Strip the AppImage runtime library path from a bun command (see
@@ -3519,4 +3521,25 @@ mod tests {
assert!(tail.starts_with("..."));
assert!(tail.ends_with('é'));
}
+
+ #[cfg(target_os = "linux")]
+ #[test]
+ fn scrub_bun_runtime_env_always_removes_ld_library_path_on_linux() {
+ use std::ffi::OsStr;
+
+ let mut cmd = std::process::Command::new("sh");
+ cmd.env("LD_LIBRARY_PATH", "/tmp/appimage/usr/lib");
+
+ scrub_bun_runtime_env(&mut cmd);
+
+ let env_value = cmd
+ .get_envs()
+ .find(|(key, _)| *key == OsStr::new("LD_LIBRARY_PATH"))
+ .map(|(_, value)| value);
+ assert_eq!(
+ env_value,
+ Some(None),
+ "bun subprocesses on Linux must clear inherited LD_LIBRARY_PATH"
+ );
+ }
}