Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix: path of bun to start gateway on Linux
Vanalitea327c8385873
diff --git a/src-tauri/src/core/openclaw/cli.rs b/src-tauri/src/core/openclaw/cli.rsindex abd6dfc5e..2bb604344 100644--- a/src-tauri/src/core/openclaw/cli.rs+++ b/src-tauri/src/core/openclaw/cli.rs@@ -20,20 +20,33 @@ fn hide_window(cmd: &mut Command) {fn hide_window(_cmd: &mut Command) {}/// Helper to build a command with resolved openclaw path and PATH injection.+///+/// When bundled Bun is available, uses `bun <openclaw_path> <args>` to avoid+/// shebang resolution issues (old system node, missing node shim, etc.).fn build_openclaw_command(args: &[&str]) -> Command {- // Ensure node shim points to bundled Bun (for shebang resolution)+ // Ensure node shim points to bundled Bun (for shebang resolution fallback)if let Err(e) = super::ensure_bun_node_shim() {log::debug!("Node shim not created (will fall back to system node): {}", e);}- // Try to use the installed openclaw binary in the runtime directorylet openclaw_path = super::get_openclaw_bin_path().ok();let use_installed_binary = openclaw_path.as_ref().map(|p| p.exists()).unwrap_or(false);+ let bun_path = super::resolve_bundled_bun();- if use_installed_binary {+ if use_installed_binary && bun_path.is_some() {+ // Best path: run bun explicitly as the interpreter for the openclaw script+ let mut cmd = Command::new(bun_path.unwrap());+ cmd.arg(openclaw_path.unwrap());+ if let Some(new_path) = super::build_augmented_path() {+ cmd.env("PATH", new_path);+ }+ cmd.args(args);+ hide_window(&mut cmd);+ cmd+ } else if use_installed_binary {let mut cmd = Command::new(openclaw_path.unwrap());if let Some(new_path) = super::build_augmented_path() {cmd.env("PATH", new_path);@@ -58,7 +71,14 @@ async fn check_openclaw_installed() -> Result<Option<String>, String> {// Try the installed openclaw binary in the runtime directoryif let Ok(openclaw_path) = super::get_openclaw_bin_path() {if openclaw_path.exists() {- let mut cmd = Command::new(&openclaw_path);+ // Use bun as explicit interpreter when available (avoids shebang issues)+ let mut cmd = if let Some(bun_path) = super::resolve_bundled_bun() {+ let mut c = Command::new(bun_path);+ c.arg(&openclaw_path);+ c+ } else {+ Command::new(&openclaw_path)+ };cmd.arg("--version");if let Some(new_path) = super::build_augmented_path() {cmd.env("PATH", new_path);diff --git a/src-tauri/src/core/openclaw/commands.rs b/src-tauri/src/core/openclaw/commands.rsindex b485c06f1..534564171 100644--- a/src-tauri/src/core/openclaw/commands.rs+++ b/src-tauri/src/core/openclaw/commands.rs@@ -66,19 +66,30 @@ async fn openclaw_command(args: &[&str]) -> Command {hide_window(&mut cmd);cmd} else {- // Ensure node shim points to bundled Bun (for shebang resolution)+ // Ensure node shim points to bundled Bun (for shebang resolution fallback)if let Err(e) = super::ensure_bun_node_shim() {log::debug!("Node shim not created (will fall back to system node): {}", e);}- // 1. Try the installed openclaw binary firstlet openclaw_path = super::get_openclaw_bin_path().ok();let use_installed_binary = openclaw_path.as_ref().map(|p| p.exists()).unwrap_or(false);-- let mut cmd = if use_installed_binary {+ let bun_path = super::resolve_bundled_bun();++ // When bundled Bun is available, use it as the explicit interpreter for+ // the openclaw script. This bypasses shebang resolution entirely — avoids+ // issues with old system node or missing node shim.+ let mut cmd = if use_installed_binary && bun_path.is_some() {+ let mut c = Command::new(bun_path.unwrap());+ c.arg(openclaw_path.unwrap());+ if let Some(new_path) = super::build_augmented_path() {+ c.env("PATH", new_path);+ }+ c.args(args);+ c+ } else if use_installed_binary {let mut c = Command::new(openclaw_path.unwrap());if let Some(new_path) = super::build_augmented_path() {c.env("PATH", new_path);@@ -86,7 +97,7 @@ async fn openclaw_command(args: &[&str]) -> Command {c.args(args);c} else {- // 2. Fallback: bare "openclaw" (user installed via npm or has it in PATH)+ // Fallback: bare "openclaw" (user installed via npm or has it in PATH)let mut c = Command::new("openclaw");if let Some(new_path) = super::build_augmented_path() {c.env("PATH", new_path);diff --git a/src-tauri/src/core/openclaw/sandbox_direct.rs b/src-tauri/src/core/openclaw/sandbox_direct.rsindex 493c4f308..00f2dedd2 100644--- a/src-tauri/src/core/openclaw/sandbox_direct.rs+++ b/src-tauri/src/core/openclaw/sandbox_direct.rs@@ -7,17 +7,28 @@ use super::sandbox::{IsolationTier, Sandbox, SandboxConfig, SandboxHandle, Sandbpub struct DirectProcessSandbox;/// Helper to build a command with resolved openclaw path and PATH injection.+///+/// When bundled Bun is available, uses `bun <openclaw_path> <args>` to avoid+/// shebang resolution issues (old system node, missing node shim, etc.).fn build_openclaw_command(args: &[&str], config_dir: &std::path::Path) -> tokio::process::Command {- // Try to use the installed openclaw binary in the runtime directorylet openclaw_path = super::get_openclaw_bin_path().ok();let use_installed_binary = openclaw_path.as_ref().map(|p| p.exists()).unwrap_or(false);-- let mut cmd = if use_installed_binary {+ let bun_path = super::resolve_bundled_bun();++ let mut cmd = if use_installed_binary && bun_path.is_some() {+ // Best path: run bun explicitly as the interpreter for the openclaw script.+ // This bypasses shebang resolution entirely — no dependency on `node` in PATH.+ let mut c = tokio::process::Command::new(bun_path.unwrap());+ c.arg(openclaw_path.unwrap());+ c+ } else if use_installed_binary {+ // Bun not available, run openclaw script directly (relies on shebang → system node)tokio::process::Command::new(openclaw_path.unwrap())} else {+ // Fallback: bare "openclaw" (user installed via npm or has it in PATH)tokio::process::Command::new("openclaw")};@@ -74,8 +85,19 @@ impl Sandbox for DirectProcessSandbox {vec!["gateway", "install"]};let mut install_cmd = build_openclaw_command(&install_args.iter().map(|s| *s).collect::<Vec<_>>(), &config.config_dir);- if let Ok(mut install_child) = install_cmd.spawn() {- let _ = install_child.wait().await;+ match install_cmd.output().await {+ Ok(output) => {+ if output.status.success() {+ log::info!("gateway install succeeded: {}", String::from_utf8_lossy(&output.stdout).trim());+ } else {+ let stderr = String::from_utf8_lossy(&output.stderr);+ let stdout = String::from_utf8_lossy(&output.stdout);+ log::error!("gateway install failed (exit {}): stdout={}, stderr={}", output.status, stdout.trim(), stderr.trim());+ }+ }+ Err(e) => {+ log::error!("Failed to run gateway install: {}", e);+ }}// Start OpenClaw gateway via CLI