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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(linux): Runde-2-Nachbesserungen: Quellwaechter, echte ID_LIKE-Faelle, Kommentar
purple9f5f6005b204
diff --git a/src-tauri/src/commands/install/comfy_install.rs b/src-tauri/src/commands/install/comfy_install.rsindex c6e955ca..80bcff62 100644--- a/src-tauri/src/commands/install/comfy_install.rs+++ b/src-tauri/src/commands/install/comfy_install.rs@@ -1065,3 +1065,48 @@ mod disk_pressure_doc_matches_body {);}}++/// Review Runde 2, B1: nothing may delete the Linux git preflight in+/// `install_comfyui` or move it after the first network write it is meant+/// to guard, without a test going red. Same include_str! + marker technique+/// as `update_checks_the_interpreter_before_pulling_the_repository` in+/// comfy_repair.rs and `the_argv_matchers_share_one_refresh` in+/// process_util.rs: read the file's own source, cut it at the function+/// signature, and require the preflight call text to occur before both+/// download literals the function can hit ("clone" for the fresh install,+/// "pull" for the "already exists, update it" branch).+#[cfg(test)]+mod git_preflight_call_site_guard {+ #[test]+ fn install_comfyui_checks_git_before_clone_and_before_pull() {+ let src = include_str!("comfy_install.rs");+ let fn_start = src+ .find("pub fn install_comfyui(")+ .expect("install_comfyui is gone from comfy_install.rs");+ let body = &src[fn_start..];++ let at_preflight = body.find("git_download_preflight()").expect(+ "install_comfyui no longer calls git_download_preflight(): a fresh \+ Debian 13 or Fedora 43 box without git would clone straight into a \+ cryptic spawn error again instead of the distro-specific hint",+ );+ let at_clone = body+ .find("\"clone\"")+ .expect("the git clone literal is gone from install_comfyui");+ let at_pull = body+ .find("\"pull\"")+ .expect("the git pull literal (already-exists branch) is gone from install_comfyui");++ assert!(+ at_preflight < at_clone,+ "git_download_preflight() (byte {at_preflight}) must run before the \+ clone (byte {at_clone}), not after"+ );+ assert!(+ at_preflight < at_pull,+ "git_download_preflight() (byte {at_preflight}) must run before the \+ already-exists pull (byte {at_pull}) too: both start from the same \+ preflight call, which is single, up front"+ );+ }+}diff --git a/src-tauri/src/commands/install/comfy_repair.rs b/src-tauri/src/commands/install/comfy_repair.rsindex 1fc50810..ea239c77 100644--- a/src-tauri/src/commands/install/comfy_repair.rs+++ b/src-tauri/src/commands/install/comfy_repair.rs@@ -2106,3 +2106,34 @@ mod tests {);}}++/// Review Runde 2, B1: nothing may delete the Linux git preflight in+/// `update_comfyui` or move it after the `git pull --ff-only` it is meant+/// to guard, without a test going red. Same technique as+/// `update_checks_the_interpreter_before_pulling_the_repository` above.+#[cfg(test)]+mod git_preflight_call_site_guard {+ #[test]+ fn update_comfyui_checks_git_before_pull() {+ let src = include_str!("comfy_repair.rs");+ let fn_start = src+ .find("pub fn update_comfyui(")+ .expect("update_comfyui is gone from comfy_repair.rs");+ let body = &src[fn_start..];++ let at_preflight = body.find("git_download_preflight()").expect(+ "update_comfyui no longer calls git_download_preflight(): a fresh \+ Debian 13 or Fedora 43 box without git would pull straight into a \+ cryptic spawn error again instead of the distro-specific hint",+ );+ let at_pull = body+ .find("\"pull\"")+ .expect("the git pull literal is gone from update_comfyui");++ assert!(+ at_preflight < at_pull,+ "git_download_preflight() (byte {at_preflight}) must run before \+ git pull --ff-only (byte {at_pull}), not after"+ );+ }+}diff --git a/src-tauri/src/commands/install/custom_nodes.rs b/src-tauri/src/commands/install/custom_nodes.rsindex 3685d43c..b60bd875 100644--- a/src-tauri/src/commands/install/custom_nodes.rs+++ b/src-tauri/src/commands/install/custom_nodes.rs@@ -727,3 +727,42 @@ mod tests {assert!(outcome.needs_reverification());}}++/// Review Runde 2, B1: nothing may delete the Linux git preflight in+/// `install_custom_node_blocking` or move it after the pull or the clone it+/// is meant to guard, without a test going red. Same technique as+/// process_util.rs's `the_argv_matchers_share_one_refresh`.+#[cfg(test)]+mod git_preflight_call_site_guard {+ #[test]+ fn install_custom_node_checks_git_before_pull_and_before_clone() {+ let src = include_str!("custom_nodes.rs");+ let fn_start = src+ .find("fn install_custom_node_blocking(")+ .expect("install_custom_node_blocking is gone from custom_nodes.rs");+ let body = &src[fn_start..];++ let at_preflight = body.find("git_download_preflight()").expect(+ "install_custom_node_blocking no longer calls git_download_preflight(): \+ a fresh Debian 13 or Fedora 43 box without git would clone or pull \+ straight into a cryptic spawn error again",+ );+ let at_pull = body+ .find("\"pull\"")+ .expect("the git pull literal (update branch) is gone from install_custom_node_blocking");+ let at_clone = body+ .find("\"clone\"")+ .expect("the git clone literal (fresh install branch) is gone from install_custom_node_blocking");++ assert!(+ at_preflight < at_pull,+ "git_download_preflight() (byte {at_preflight}) must run before the \+ update pull (byte {at_pull}), not after"+ );+ assert!(+ at_preflight < at_clone,+ "git_download_preflight() (byte {at_preflight}) must run before the \+ fresh clone (byte {at_clone}), not after"+ );+ }+}diff --git a/src-tauri/src/commands/install/git.rs b/src-tauri/src/commands/install/git.rsindex f384cbe1..e2385369 100644--- a/src-tauri/src/commands/install/git.rs+++ b/src-tauri/src/commands/install/git.rs@@ -261,10 +261,19 @@ pub fn linux_git_missing_message(os_release: &str) -> String {}#[cfg_attr(not(target_os = "linux"), allow(dead_code))]-fn read_os_release() -> String {+pub fn read_os_release() -> String {std::fs::read_to_string("/etc/os-release").unwrap_or_default()}+/// Whether `git --version` succeeds, exposed as its own call so a caller+/// that needs the yes/no answer for more than the network preflight (the+/// trainer's archive-then-git fallback, review Runde 2 Nachbesserung 2)+/// probes git exactly once instead of running `git --version` a second+/// time right after `git_download_preflight` already ran it.+pub fn is_git_present() -> bool {+ git_version_string().is_some()+}+/// Pure core of [`git_download_preflight`]: whether git is present in, the/// hint to abort with (or `None` to proceed) out. Kept separate from the OS/// probe so the "git missing -> block before any download" behaviour is a@@ -293,7 +302,7 @@ fn git_download_preflight_core(is_git_present: bool, os_release: &str) -> Option/// so callers see no behaviour change there.#[cfg(target_os = "linux")]pub fn git_download_preflight() -> Option<String> {- git_download_preflight_core(git_version_string().is_some(), &read_os_release())+ git_download_preflight_core(is_git_present(), &read_os_release())}#[cfg(not(target_os = "linux"))]@@ -515,8 +524,12 @@ mod tests {#[test]fn linux_pm_debian_derivative_via_id_like_is_apt() {- // Linux Mint style: ID is its own name, ID_LIKE carries the upstream.- let os_release = "NAME=\"Linux Mint\"\nID=linuxmint\nID_LIKE=\"ubuntu debian\"\n";+ // Review Runde 2, B2: the old example here was Linux Mint+ // (ID=linuxmint), but "linuxmint" is itself in the Apt match list,+ // so that test passed even with ID_LIKE completely ignored: it+ // never actually exercised the ID_LIKE path. Zorin OS's own ID is+ // not in any family list; only ID_LIKE carries "ubuntu debian".+ let os_release = "NAME=\"Zorin OS\"\nID=zorin\nID_LIKE=\"ubuntu debian\"\n";assert_eq!(linux_package_manager_from_os_release(os_release),LinuxPackageManager::Apt@@ -534,7 +547,11 @@ mod tests {#[test]fn linux_pm_rhel_derivative_via_id_like_is_dnf() {- let os_release = "NAME=\"Rocky Linux\"\nID=rocky\nID_LIKE=\"rhel centos fedora\"\n";+ // Review Runde 2, B2: the old example here was Rocky Linux+ // (ID=rocky), but "rocky" is itself in the Dnf match list, so this+ // test passed even with ID_LIKE completely ignored. Nobara's own ID+ // is not in any family list; only ID_LIKE carries "fedora".+ let os_release = "NAME=\"Nobara Linux\"\nID=nobara\nID_LIKE=fedora\n";assert_eq!(linux_package_manager_from_os_release(os_release),LinuxPackageManager::Dnf@@ -550,6 +567,18 @@ mod tests {);}+ #[test]+ fn linux_pm_arch_derivative_via_id_like_is_pacman() {+ // Review Runde 2, B2: no Pacman example went through ID_LIKE at+ // all before this. CachyOS's own ID is not in any family list;+ // only ID_LIKE carries "arch".+ let os_release = "NAME=\"CachyOS Linux\"\nID=cachyos\nID_LIKE=arch\n";+ assert_eq!(+ linux_package_manager_from_os_release(os_release),+ LinuxPackageManager::Pacman+ );+ }+#[test]fn linux_pm_opensuse_is_zypper() {let os_release = "NAME=\"openSUSE Leap\"\nID=opensuse-leap\nID_LIKE=\"suse opensuse\"\n";diff --git a/src-tauri/src/commands/trainer.rs b/src-tauri/src/commands/trainer.rsindex b018ab65..a1578921 100644--- a/src-tauri/src/commands/trainer.rs+++ b/src-tauri/src/commands/trainer.rs@@ -1884,8 +1884,13 @@ pub(crate) fn musubi_source_present(root: &Path) -> bool {}/// Step 1 without a git binary: the tag as an archive, unpacked into place.-/// git is the fallback, not the requirement, so a machine without it gets the-/// network sentence when the archive fails, never "install git first".+/// git is the fallback the source falls back to, not a requirement checked+/// up front, so a machine without it only hears about git once the archive+/// has already failed. On Linux that answer names the exact package manager+/// command (review Runde 2, B3: this used to say the opposite, "never+/// install git first", which stopped being true the moment the preflight+/// below was added); on Windows and macOS it stays the plain network+/// sentence it always was.fn fetch_musubi_source(root: &Path,state: &Arc<Mutex<crate::state::InstallState>>,@@ -1900,19 +1905,25 @@ fn fetch_musubi_source(Err(e) if e == "cancelled" => return Err(e),Err(e) => e,};- // Linux setup stolpstein (BERICHT-5-APPIMAGE.md): fresh Debian 13 and- // Fedora 43 cloud/desktop images ship no git at all, so name the exact- // package manager command instead of a bare "could not download".- if let Some(hint) = crate::commands::install::git::git_download_preflight() {- return Err(format!("Could not download the trainer source: {archive_err}\n\n{hint}"));- }- let mut git = crate::process_util::foreign_system_command("git");- git.arg("--version");- #[cfg(target_os = "windows")]- git.creation_flags(CREATE_NO_WINDOW);- let has_git = git.output().map(|o| o.status.success()).unwrap_or(false);+ // One git probe for both platform decisions (review Runde 2,+ // Nachbesserung 2: this used to run `git --version` a second time right+ // after git_download_preflight() already ran it). Linux setup+ // stolpstein (BERICHT-5-APPIMAGE.md): fresh Debian 13 and Fedora 43+ // cloud/desktop images ship no git at all, so name the exact package+ // manager command instead of a bare "could not download" there.+ let has_git = crate::commands::install::git::is_git_present();if !has_git {- return Err(format!("Could not download the trainer source: {archive_err}"));+ #[cfg(target_os = "linux")]+ {+ let hint = crate::commands::install::git::linux_git_missing_message(+ &crate::commands::install::git::read_os_release(),+ );+ return Err(format!("Could not download the trainer source: {archive_err}\n\n{hint}"));+ }+ #[cfg(not(target_os = "linux"))]+ {+ return Err(format!("Could not download the trainer source: {archive_err}"));+ }}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));@@ -5395,3 +5406,56 @@ mod progress_line_tests {assert!(!body.contains(".lines()"), "BufRead::lines would hide tqdm updates until the epoch ends");}}++/// Review Runde 2, B1: nothing may delete the Linux git preflight in+/// `fetch_musubi_source` or move it after the `git clone` it is meant to+/// guard, without a test going red. Same technique as+/// process_util.rs's `the_argv_matchers_share_one_refresh`.+#[cfg(test)]+mod git_preflight_call_site_guard {+ #[test]+ fn fetch_musubi_source_checks_git_before_clone() {+ let src = include_str!("trainer.rs");+ let fn_start = src+ .find("fn fetch_musubi_source(")+ .expect("fetch_musubi_source is gone from trainer.rs");+ let body = &src[fn_start..];++ let at_probe = body.find("is_git_present()").expect(+ "fetch_musubi_source no longer probes git before falling back to it: a \+ fresh Debian 13 or Fedora 43 box without git would clone straight into \+ a cryptic spawn error again instead of the distro-specific hint",+ );+ // The probe alone is not the whole guarantee: review Runde 2 merged+ // the old git_download_preflight() call into is_git_present() plus+ // this direct call to the same Linux hint builder, to avoid running+ // `git --version` twice. Anchoring only on is_git_present() would+ // stay green even if someone deleted the `#[cfg(target_os =+ // "linux")]` arm that actually builds the distro-specific message,+ // so the hint builder call has to be found too.+ let at_hint = body.find("linux_git_missing_message(").expect(+ "fetch_musubi_source no longer builds the Linux-specific git hint: a \+ fresh Debian 13 or Fedora 43 box without git would get the bare \+ network sentence again instead of the package manager command",+ );+ let at_clone = body+ .find("\"clone\"")+ .expect("the git clone literal is gone from fetch_musubi_source");++ assert!(+ at_probe < at_clone,+ "is_git_present() (byte {at_probe}) must run before the clone \+ (byte {at_clone}), not after"+ );+ assert!(+ at_hint < at_clone,+ "linux_git_missing_message(...) (byte {at_hint}) must run before the \+ clone (byte {at_clone}), not after"+ );+ assert!(+ at_probe < at_hint,+ "is_git_present() (byte {at_probe}) must be checked before building \+ the Linux hint (byte {at_hint}), not the other way round"+ );+ }+}