Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(process): strip AppImage LD_LIBRARY_PATH before spawning foreign git/python

purple36d7e2242876
diff --git a/src-tauri/src/commands/install/comfy_install.rs b/src-tauri/src/commands/install/comfy_install.rs
index 628aaecc..259a66f5 100644
--- a/src-tauri/src/commands/install/comfy_install.rs
+++ b/src-tauri/src/commands/install/comfy_install.rs
@@ -16,7 +16,7 @@
use std::io::Read as IoRead;
use std::path::{Path, PathBuf};
-use std::process::{Command, Stdio};
+use std::process::Stdio;
use std::sync::atomic::Ordering;
#[cfg(target_os = "windows")]
@@ -317,7 +317,7 @@ pub fn install_comfyui(
println!("[Install] Cloning ComfyUI to {:?}", target_dir);
update("downloading", "Step 1/4: Downloading ComfyUI repository...");
- let mut cmd = Command::new("git");
+ let mut cmd = crate::process_util::foreign_system_command("git");
cmd.args(["clone", "https://github.com/comfyanonymous/ComfyUI.git"])
.arg(&target_dir)
.stdout(Stdio::piped())
@@ -381,7 +381,7 @@ pub fn install_comfyui(
update("cancelled", "Install cancelled.");
return;
}
- let mut pull = Command::new("git");
+ let mut pull = crate::process_util::foreign_system_command("git");
pull.args(["pull"]).current_dir(&target_dir)
.stdout(Stdio::piped()).stderr(Stdio::piped());
#[cfg(target_os = "windows")]
diff --git a/src-tauri/src/commands/install/comfy_repair.rs b/src-tauri/src/commands/install/comfy_repair.rs
index ba48e71c..02584a0d 100644
--- a/src-tauri/src/commands/install/comfy_repair.rs
+++ b/src-tauri/src/commands/install/comfy_repair.rs
@@ -20,7 +20,7 @@
//! der Nutzer nur "die Sprachausgabe ist plötzlich weg".
use std::path::PathBuf;
-use std::process::{Command, Stdio};
+use std::process::Stdio;
use std::sync::atomic::Ordering;
#[cfg(target_os = "windows")]
@@ -597,7 +597,7 @@ pub fn update_comfyui(state: State<'_, AppState>) -> Result<serde_json::Value, S
}
update("installing", "Step 1/3: Pulling the latest ComfyUI...");
- let mut pull = Command::new("git");
+ let mut pull = crate::process_util::foreign_system_command("git");
// --ff-only: a user-modified checkout must not silently merge; surface
// the divergence honestly instead.
pull.args(["pull", "--ff-only"])
diff --git a/src-tauri/src/commands/install/custom_nodes.rs b/src-tauri/src/commands/install/custom_nodes.rs
index dbe101dc..1d596751 100644
--- a/src-tauri/src/commands/install/custom_nodes.rs
+++ b/src-tauri/src/commands/install/custom_nodes.rs
@@ -26,7 +26,7 @@ use std::fs;
use std::path::PathBuf;
use crate::python::python_command;
use super::pip::is_permission_denied_pip_error;
-use std::process::{Command, Stdio};
+use std::process::Stdio;
#[cfg(target_os = "windows")]
use std::os::windows::process::CommandExt;
@@ -164,7 +164,7 @@ fn install_custom_node_blocking(
if target_dir.exists() {
if target_dir.join(".git").exists() {
println!("[Install] Custom node {} already exists, updating...", node_name);
- let mut cmd = Command::new("git");
+ let mut cmd = crate::process_util::foreign_system_command("git");
cmd.args(["pull"]).current_dir(&target_dir)
.stdout(Stdio::piped()).stderr(Stdio::piped());
#[cfg(target_os = "windows")]
@@ -194,7 +194,7 @@ fn install_custom_node_blocking(
if fresh_clone {
println!("[Install] Cloning custom node {} from {}", node_name, repo_url);
- let mut cmd = Command::new("git");
+ let mut cmd = crate::process_util::foreign_system_command("git");
cmd.args(["clone", &repo_url]).arg(&target_dir)
.stdout(Stdio::piped()).stderr(Stdio::piped());
#[cfg(target_os = "windows")]
diff --git a/src-tauri/src/commands/install/git.rs b/src-tauri/src/commands/install/git.rs
index 69bb2716..b619e843 100644
--- a/src-tauri/src/commands/install/git.rs
+++ b/src-tauri/src/commands/install/git.rs
@@ -14,14 +14,14 @@
//! daneben, weil die Codex-Ansicht dieselbe Sonde für ihr eigenes Banner
//! braucht — dieselbe Frage, anderer Adressat.
-use std::process::Command;
-
#[cfg(target_os = "windows")]
use std::os::windows::process::CommandExt;
#[cfg(target_os = "windows")]
use super::CREATE_NO_WINDOW;
+use crate::process_util::foreign_system_command;
+
/// Bug N — git probe before ComfyUI install (juliandiggins-stack issue #40).
///
/// On Windows the in-app ComfyUI install + custom-node install both shell out
@@ -79,7 +79,7 @@ pub fn windows_git_probe_from_output(stdout: &str, exited_successfully: bool) ->
/// platforms a stock `git` is fine.
#[cfg(target_os = "windows")]
pub fn windows_git_probe() -> WindowsGitState {
- let mut cmd = Command::new("git");
+ let mut cmd = foreign_system_command("git");
cmd.arg("--version").creation_flags(CREATE_NO_WINDOW);
match cmd.output() {
Ok(o) if o.status.success() => {
@@ -136,7 +136,7 @@ pub struct GitStatus {
/// Run `git --version` (no console window on Windows) and return the trimmed
/// stdout line, or `None` if git is missing / failed to run.
fn git_version_string() -> Option<String> {
- let mut cmd = Command::new("git");
+ let mut cmd = foreign_system_command("git");
cmd.arg("--version");
#[cfg(target_os = "windows")]
{
diff --git a/src-tauri/src/commands/trainer.rs b/src-tauri/src/commands/trainer.rs
index 3d4e5aed..b83c4901 100644
--- a/src-tauri/src/commands/trainer.rs
+++ b/src-tauri/src/commands/trainer.rs
@@ -1298,7 +1298,7 @@ fn fetch_musubi_source(
Err(e) if e == "cancelled" => return Err(e),
Err(e) => e,
};
- let mut git = Command::new("git");
+ let mut git = crate::process_util::foreign_system_command("git");
git.arg("--version");
#[cfg(target_os = "windows")]
git.creation_flags(CREATE_NO_WINDOW);
@@ -1308,7 +1308,7 @@ fn fetch_musubi_source(
}
push_log(state, &format!("Could not get the trainer source as an archive ({archive_err}); getting it with git instead."));
let _ = fs::remove_dir_all(repo_dir(root));
- let mut clone = Command::new("git");
+ let mut clone = crate::process_util::foreign_system_command("git");
clone.args(["clone", "--branch", MUSUBI_TAG, "--depth", "1", MUSUBI_REPO])
.arg(repo_dir(root));
run_streamed(clone, "git clone", state, cancel, pid_slot)
diff --git a/src-tauri/src/process_util.rs b/src-tauri/src/process_util.rs
index bf01c3a9..2db45d1e 100644
--- a/src-tauri/src/process_util.rs
+++ b/src-tauri/src/process_util.rs
@@ -29,6 +29,182 @@ pub fn suppress_window(cmd: &mut Command) {
}
}
+// ── K11: foreign programs vs. our own bundled sidecars on Linux AppImage ────
+//
+// K2/K11 (Discord, mallic, 2026-09-16, CachyOS/Arch AppImage): after an
+// in-app update, `git clone` inside the app failed with "no version
+// information available" and custom-node installs broke the same way.
+// Reinstalling did not help.
+//
+// linuxdeploy's AppRun exports `LD_LIBRARY_PATH` by PREPENDING
+// `$APPDIR/usr/lib[/x86_64-linux-gnu]` onto whatever the shell already had,
+// so it is inherited by every child process — including a system `git` found
+// on PATH. On Arch/CachyOS, whose `libpcre2-8`/`libssl` are newer than the
+// ones linuxdeploy bundled for the build host, the system `git` binary links
+// against ITS OWN system libpcre2/libssl by SONAME, the dynamic loader finds
+// LU's older bundled copies FIRST because of the inherited path, and either
+// a symbol-versioning mismatch ("no version information available") or an
+// outright crash follows. `python.rs::sanitize_appimage_python_env` already
+// fixed the equivalent bug for `PYTHONHOME`/`PYTHONPATH`, but deliberately
+// leaves `LD_LIBRARY_PATH` alone GLOBALLY — our own bundled sidecars (the
+// llama.cpp server, `whisper_server.py`'s interpreter, ...) need exactly the
+// libraries that variable points at. So this fix is scoped per spawned
+// command instead of touching the process-wide environment: only the one
+// child actually being started gets the cleaned value.
+
+/// The `LD_LIBRARY_PATH` a FOREIGN system program should see, given the
+/// value this process inherited and the AppImage's own mount point, or
+/// `None` when nothing needs to change (nothing in `current` lives under
+/// `appdir`, or `current` is empty).
+///
+/// Pure so the AppImage case is testable on every platform this app builds
+/// for, none of which sets `APPDIR` in CI.
+///
+/// There is no separate variable the AppImage runtime saves the ORIGINAL
+/// `LD_LIBRARY_PATH` under (unlike `APPIMAGE`/`APPDIR`/`OWD`/`ARGV0`, which
+/// `self_migrate.rs` already restores/clears around a relaunch) — the
+/// original value is simply whatever came AFTER the prepended AppDir
+/// entries, which for the ordinary case of LU started from a desktop icon
+/// is nothing at all. So "restore the original" and "strip the AppImage
+/// entries" are the same operation here.
+pub fn appimage_ld_library_path_without_appdir(current: &str, appdir: &str) -> Option<String> {
+ if current.is_empty() {
+ return None;
+ }
+ let appdir = appdir.trim_end_matches('/');
+ if appdir.is_empty() {
+ return None;
+ }
+ let entries: Vec<&str> = current.split(':').collect();
+ let kept: Vec<&str> = entries
+ .iter()
+ .copied()
+ .filter(|entry| !(entry.starts_with(appdir) && !entry.is_empty()))
+ .collect();
+ if kept.len() == entries.len() {
+ return None; // nothing pointed inside the AppImage, leave it untouched
+ }
+ Some(kept.join(":"))
+}
+
+/// Clean a child `Command`'s inherited `LD_LIBRARY_PATH` in place, for a
+/// FOREIGN system program only. No-op whenever `APPDIR` is unset — every
+/// platform and packaging but a running Linux AppImage — so this is safe to
+/// call unconditionally.
+///
+/// Never call this for our OWN bundled sidecars (the llama.cpp server, a
+/// ComfyUI venv we created, ...): they are built against and need exactly
+/// the libraries this strips out. Use [`foreign_system_command`] instead of
+/// touching this directly wherever a plain `Command::new` would do.
+pub fn strip_appimage_ld_library_path(cmd: &mut Command) {
+ let Ok(appdir) = std::env::var("APPDIR") else { return };
+ let Ok(current) = std::env::var("LD_LIBRARY_PATH") else { return };
+ if let Some(clean) = appimage_ld_library_path_without_appdir(&current, &appdir) {
+ cmd.env("LD_LIBRARY_PATH", clean);
+ }
+}
+
+/// Build a `Command` for a FOREIGN system program — `git`, a system Python
+/// interpreter, `pip`, a system `ffmpeg` — anything on `$PATH` that LU did
+/// not build and does not bundle. Use this instead of a bare `Command::new`
+/// at every such call site: it clears an AppImage's own library paths out of
+/// the child's environment (K11) so a foreign binary loads the SYSTEM
+/// libraries it actually links against, never our bundled copies. A no-op
+/// everywhere but a running Linux AppImage.
+///
+/// Do NOT use this for our own bundled sidecars — call `Command::new`
+/// directly for those, exactly as before.
+pub fn foreign_system_command<S: AsRef<std::ffi::OsStr>>(program: S) -> Command {
+ let mut cmd = Command::new(program);
+ strip_appimage_ld_library_path(&mut cmd);
+ cmd
+}
+
+#[cfg(test)]
+mod appimage_env_tests {
+ use super::*;
+
+ #[test]
+ fn appimage_entries_are_dropped_and_the_rest_survives() {
+ let appdir = "/tmp/.mount_LocallieGkad";
+ let current = "/tmp/.mount_LocallieGkad/usr/lib:/tmp/.mount_LocallieGkad/usr/lib/x86_64-linux-gnu:/usr/local/lib";
+ let clean = appimage_ld_library_path_without_appdir(current, appdir)
+ .expect("appimage entries were present and should have been stripped");
+ assert_eq!(clean, "/usr/local/lib");
+ assert!(!clean.contains(".mount_LocallieGkad"));
+ }
+
+ #[test]
+ fn a_value_with_nothing_from_the_appimage_is_left_alone() {
+ // Negative control: a user who set LD_LIBRARY_PATH themselves, or an
+ // AppImage runtime with nothing prepended, must not be rewritten —
+ // rewriting an unrelated value could break the very thing the user set.
+ assert_eq!(
+ appimage_ld_library_path_without_appdir("/usr/local/lib:/opt/cuda/lib64", "/tmp/.mount_x"),
+ None,
+ );
+ assert_eq!(appimage_ld_library_path_without_appdir("", "/tmp/.mount_x"), None);
+ assert_eq!(appimage_ld_library_path_without_appdir("/usr/local/lib", ""), None);
+ }
+
+ #[test]
+ fn the_ordinary_desktop_launch_case_strips_down_to_nothing() {
+ // The realistic case: LU started from a desktop icon, nothing set
+ // LD_LIBRARY_PATH beforehand, so the AppImage runtime's own prepend
+ // is the WHOLE value. Stripping it must leave an explicit empty
+ // string, not `None` — `None` here would mean "no AppImage prefix
+ // was found", which is false and would keep the poisoned value.
+ let appdir = "/tmp/.mount_LocallieGkad";
+ let current = "/tmp/.mount_LocallieGkad/usr/lib:/tmp/.mount_LocallieGkad/usr/lib/x86_64-linux-gnu";
+ assert_eq!(appimage_ld_library_path_without_appdir(current, appdir), Some(String::new()));
+ }
+
+ #[test]
+ fn a_trailing_slash_on_appdir_does_not_break_the_match() {
+ let appdir = "/tmp/.mount_LocallieGkad/";
+ let current = "/tmp/.mount_LocallieGkad/usr/lib:/usr/local/lib";
+ assert_eq!(
+ appimage_ld_library_path_without_appdir(current, appdir),
+ Some("/usr/local/lib".to_string()),
+ );
+ }
+
+ #[test]
+ fn foreign_system_command_is_a_noop_without_appdir() {
+ // Negative control for the whole path: with no APPDIR (every
+ // platform and packaging but a running Linux AppImage), the command
+ // must come back with no LD_LIBRARY_PATH override at all.
+ std::env::remove_var("APPDIR");
+ let cmd = foreign_system_command("git");
+ assert_eq!(cmd.get_envs().count(), 0, "no APPDIR means nothing should be overridden");
+ }
+
+ #[test]
+ fn foreign_system_command_cleans_the_env_a_spawned_git_would_inherit() {
+ // K11/K2 (mallic, CachyOS/Arch AppImage, 2026-09-16): `git` on PATH
+ // inherited the AppImage's LD_LIBRARY_PATH and loaded LU's bundled
+ // libpcre2/libssl instead of the system's, printing "no version
+ // information available". This is the exact call every
+ // `Command::new("git")` in the codebase was switched to.
+ std::env::set_var("APPDIR", "/tmp/.mount_LocallieGkad");
+ std::env::set_var(
+ "LD_LIBRARY_PATH",
+ "/tmp/.mount_LocallieGkad/usr/lib:/tmp/.mount_LocallieGkad/usr/lib/x86_64-linux-gnu",
+ );
+ let cmd = foreign_system_command("git");
+ let ld = cmd
+ .get_envs()
+ .find(|(k, _)| *k == std::ffi::OsStr::new("LD_LIBRARY_PATH"))
+ .and_then(|(_, v)| v)
+ .map(|v| v.to_string_lossy().into_owned());
+ assert_eq!(ld.as_deref(), Some(""), "both entries were inside the AppImage and should be gone");
+ assert_eq!(cmd.get_program(), "git");
+ std::env::remove_var("APPDIR");
+ std::env::remove_var("LD_LIBRARY_PATH");
+ }
+}
+
+
// ── Reading the process table by COMMAND LINE ───────────────────────────────
//
// `System::refresh_processes` does NOT fetch command lines. Its refresh kind is
diff --git a/src-tauri/src/python.rs b/src-tauri/src/python.rs
index 54f88f15..a7d0e541 100644
--- a/src-tauri/src/python.rs
+++ b/src-tauri/src/python.rs
@@ -27,6 +27,15 @@ pub fn python_command<S: AsRef<std::ffi::OsStr>>(python_bin: S) -> Command {
cmd.env("PYTHONUTF8", "1");
#[cfg(target_os = "windows")]
cmd.creation_flags(CREATE_NO_WINDOW);
+ // K11: the interpreter this runs is always the SYSTEM Python (or a venv
+ // built from it), never a Python LU bundles itself — so it is a foreign
+ // program in exactly the sense `foreign_system_command` names, and pip
+ // (always invoked as `<python> -m pip`, see install/pip.rs) rides along
+ // for free. `sanitize_appimage_python_env` above cleans PYTHONHOME/
+ // PYTHONPATH globally at startup; LD_LIBRARY_PATH cannot be cleaned that
+ // way because our OWN sidecars need it, so it is stripped here, per
+ // child, instead.
+ crate::process_util::strip_appimage_ld_library_path(&mut cmd);
cmd
}
@@ -558,6 +567,36 @@ mod tests {
assert_eq!(cmd.get_program(), "python3", "das Programm darf nicht verloren gehen");
}
+ #[test]
+ fn python_command_strips_an_appimage_ld_library_path() {
+ // K11: the interpreter python_command builds is always the SYSTEM
+ // python (or a venv on top of it), never something LU bundles, so it
+ // must not inherit an AppImage's own library path the way `git` did
+ // on CachyOS/Arch (K2/K11 field report, mallic 2026-09-16).
+ std::env::set_var("APPDIR", "/tmp/.mount_LocallieGkad");
+ std::env::set_var(
+ "LD_LIBRARY_PATH",
+ "/tmp/.mount_LocallieGkad/usr/lib:/usr/local/lib",
+ );
+ let cmd = python_command("python3");
+ let ld = cmd
+ .get_envs()
+ .find(|(k, _)| *k == std::ffi::OsStr::new("LD_LIBRARY_PATH"))
+ .and_then(|(_, v)| v)
+ .map(|v| v.to_string_lossy().into_owned());
+ assert_eq!(ld.as_deref(), Some("/usr/local/lib"), "the AppImage entry should have been stripped");
+
+ // Negative control: without APPDIR (every platform but a running
+ // Linux AppImage) nothing overrides LD_LIBRARY_PATH at all.
+ std::env::remove_var("APPDIR");
+ let cmd = python_command("python3");
+ assert!(
+ cmd.get_envs().all(|(k, _)| k != std::ffi::OsStr::new("LD_LIBRARY_PATH")),
+ "no APPDIR means LD_LIBRARY_PATH must be left untouched"
+ );
+ std::env::remove_var("LD_LIBRARY_PATH");
+ }
+
#[test]
fn python_command_takes_a_path_as_well_as_a_string() {
// Die Aufrufstellen halten mal einen String, mal einen Pfad. Beide