Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Desktop: fix Linux AppImage compatibility on newer distributions (#7953)
oobaboogaf1649ec9ef50
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.ymlindex 7e0a365ddff..4b9401d1cd1 100644--- a/.github/workflows/release-desktop.yml+++ b/.github/workflows/release-desktop.yml@@ -446,11 +446,14 @@ jobs:if (Array.isArray(targets) && targets.some((target) => String(target).toLowerCase() === 'rpm')) {throw new Error('Desktop release must not target RPM packages');}+ if (Array.isArray(targets) && targets.some((target) => String(target).toLowerCase() === 'appimage')) {+ throw new Error('Tauri AppImage bundling must stay disabled; the release uses the thin AppImage packager');+ }if (config.bundle?.linux?.rpm) {throw new Error('bundle.linux.rpm must not be configured');}- if (config.bundle?.linux?.appimage?.bundleMediaFramework !== false) {- throw new Error('Linux AppImage bundleMediaFramework must stay false');+ if (config.bundle?.linux?.appimage) {+ throw new Error('bundle.linux.appimage must not be configured for the thin AppImage release path');}const workflow = readFileSync('.github/workflows/release-desktop.yml', 'utf8');@@ -463,23 +466,24 @@ jobs:if (!linuxInstallLines.some((line) => line.includes('libappindicator3-dev'))) {throw new Error('Desktop Linux release must install libappindicator3-dev');}- const linuxdeployLines = lines.filter((line) => line.includes('github.com/linuxdeploy/linuxdeploy/releases/download'));- if (!linuxdeployLines.some((line) => line.includes('1-alpha-20250213-2/linuxdeploy-x86_64.AppImage'))) {- throw new Error('Desktop Linux release must pin linuxdeploy 1-alpha-20250213-2');+ const appimagetoolLines = lines.filter((line) => line.includes('github.com/AppImage/appimagetool/releases/download'));+ if (!appimagetoolLines.some((line) => line.includes('1.9.1/appimagetool-x86_64.AppImage'))) {+ throw new Error('Desktop Linux release must pin appimagetool 1.9.1');}// A pinned version/path is reproducibility, not integrity: the asset// can be replaced after upload. Require the immutable SHA-256 digest// to be pinned AND verified before chmod +x. Scope every check to the- // real "Pin linuxdeploy for AppImage" step so this guard cannot+ // real "Pin thin AppImage toolchain" step so this guard cannot// satisfy itself; a file-wide scan would match the guard's own code.- const expectedLinuxdeployDigest = '4648f278ab3ef31f819e67c30d50f462640e5365a77637d7e6f2ad9fd0b4522a';+ const expectedAppimagetoolDigest = 'ed4ce84f0d9caff66f50bcca6ff6f35aae54ce8135408b3fa33abfc3cb384eb0';+ const expectedRuntimeDigest = '2fca8b443c92510f1483a883f60061ad09b46b978b2631c807cd873a47ec260d';const isComment = (line) => {const trimmed = line.trim();return trimmed.startsWith('#') || trimmed.startsWith('//');};- const stepStart = lines.findIndex((line) => /^\s*- name: Pin linuxdeploy for AppImage\s*$/.test(line));+ const stepStart = lines.findIndex((line) => /^\s*- name: Pin thin AppImage toolchain\s*$/.test(line));if (stepStart === -1) {- throw new Error('Desktop Linux release must keep the "Pin linuxdeploy for AppImage" step');+ throw new Error('Desktop Linux release must keep the "Pin thin AppImage toolchain" step');}const stepIndent = lines[stepStart].search(/\S/);let stepEnd = lines.length;@@ -495,18 +499,26 @@ jobs:}}const stepLines = lines.slice(stepStart, stepEnd);- const digestEnvRe = /^\s*LINUXDEPLOY_SHA256:\s*["']([0-9a-f]{64})["']\s*$/;- const digestEnvLine = stepLines.find((line) => digestEnvRe.test(line));- if (!digestEnvLine || digestEnvLine.match(digestEnvRe)[1] !== expectedLinuxdeployDigest) {- throw new Error('Desktop Linux release must pin the linuxdeploy SHA-256 digest in the LINUXDEPLOY_SHA256 env');+ const digest = (name) => {+ const pattern = new RegExp(`^\\s*${name}:\\s*["']([0-9a-f]{64})["']\\s*$`);+ const line = stepLines.find((candidate) => pattern.test(candidate));+ return line?.match(pattern)?.[1];+ };+ if (digest('APPIMAGETOOL_SHA256') !== expectedAppimagetoolDigest) {+ throw new Error('Desktop Linux release must pin the appimagetool SHA-256 digest');}- const sha256Idx = stepLines.findIndex((line) => !isComment(line) && line.includes('sha256sum -c'));- if (sha256Idx === -1) {- throw new Error('Desktop Linux release must verify the linuxdeploy digest with sha256sum -c before use');+ if (digest('APPIMAGE_RUNTIME_SHA256') !== expectedRuntimeDigest) {+ throw new Error('Desktop Linux release must pin the AppImage runtime SHA-256 digest');+ }+ const sha256Indexes = stepLines+ .map((line, index) => !isComment(line) && line.includes('sha256sum -c') ? index : -1)+ .filter((index) => index !== -1);+ if (sha256Indexes.length !== 2) {+ throw new Error('Desktop Linux release must verify both AppImage toolchain digests');}const chmodIdx = stepLines.findIndex((line) => !isComment(line) && /chmod\s+\+x/.test(line));- if (chmodIdx !== -1 && sha256Idx > chmodIdx) {- throw new Error('Desktop Linux release must verify the linuxdeploy digest before chmod +x');+ if (chmodIdx !== -1 && Math.max(...sha256Indexes) > chmodIdx) {+ throw new Error('Desktop Linux release must verify the AppImage toolchain before chmod +x');}const releaseBody = process.env.DESKTOP_RELEASE_NOTES;if (!releaseBody) {@@ -666,45 +678,97 @@ jobs:trusted-signing-cli --version || Write-Output "trusted-signing-cli failed to run"# ── Linux: pin AppImage packaging toolchain ──- - name: Pin linuxdeploy for AppImage+ - name: Pin thin AppImage toolchainif: matrix.platform == 'ubuntu-22.04'shell: bashenv:# Pinning the versioned release path is reproducibility, not# integrity: a GitHub release asset can be replaced (or its delivery- # path compromised) after upload. The SHA-256 below is the immutable- # digest of this exact asset and is the integrity gate. If linuxdeploy- # publishes a new build under this tag, this run fails closed and the- # digest must be re-pinned deliberately.- LINUXDEPLOY_URL: "https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20250213-2/linuxdeploy-x86_64.AppImage"- LINUXDEPLOY_SHA256: "4648f278ab3ef31f819e67c30d50f462640e5365a77637d7e6f2ad9fd0b4522a"+ # path compromised) after upload. The SHA-256 digests of these exact+ # assets are the integrity gate. A replaced+ # release asset fails closed and must be re-pinned deliberately.+ APPIMAGETOOL_URL: "https://github.com/AppImage/appimagetool/releases/download/1.9.1/appimagetool-x86_64.AppImage"+ APPIMAGETOOL_SHA256: "ed4ce84f0d9caff66f50bcca6ff6f35aae54ce8135408b3fa33abfc3cb384eb0"+ APPIMAGE_RUNTIME_URL: "https://github.com/AppImage/type2-runtime/releases/download/20251108/runtime-x86_64"+ APPIMAGE_RUNTIME_SHA256: "2fca8b443c92510f1483a883f60061ad09b46b978b2631c807cd873a47ec260d"run: |set -euo pipefail- tools_dir="$RUNNER_TEMP/tauri-tools-cache/tauri"+ tools_dir="$RUNNER_TEMP/appimage-tools"mkdir -p "$tools_dir"- dest="$tools_dir/linuxdeploy-x86_64.AppImage"- curl -fsSL "$LINUXDEPLOY_URL" -o "$dest"+ appimagetool="$tools_dir/appimagetool-x86_64.AppImage"+ runtime="$tools_dir/runtime-x86_64"+ curl -fsSL "$APPIMAGETOOL_URL" -o "$appimagetool"+ curl -fsSL "$APPIMAGE_RUNTIME_URL" -o "$runtime"# Verify the digest BEFORE the binary is ever marked executable. The- # next step builds the AppImage with the Tauri signing key, so a- # substituted linuxdeploy that ran here could exfiltrate signing+ # later step builds the AppImage with the Tauri signing key, so a+ # substituted packager that ran there could exfiltrate signing# material or tamper with release artifacts. Fail closed on any# mismatch.- echo "${LINUXDEPLOY_SHA256} ${dest}" | sha256sum -c -- chmod +x "$dest"+ echo "${APPIMAGETOOL_SHA256} ${appimagetool}" | sha256sum -c -+ echo "${APPIMAGE_RUNTIME_SHA256} ${runtime}" | sha256sum -c -+ chmod +x "$appimagetool"- # ── Linux: build + sign ──- - name: Build Linux app+ # ── Linux: build the native package once ──+ - name: Build Linux debid: build_linuxif: matrix.platform == 'ubuntu-22.04'uses: tauri-apps/tauri-action@84b9d35b5fc46c1e45415bdb6144030364f7ebc5 # v0.6.2- env:- TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}- TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}- XDG_CACHE_HOME: ${{ runner.temp }}/tauri-tools-cachewith:projectPath: studiotauriScript: npx --prefix . tauri- args: -v ${{ matrix.args }}+ args: >-+ -v --bundles deb+ --config '{"bundle":{"createUpdaterArtifacts":false}}'++ # ── Linux: wrap the deb payload without bundling the GTK/WebKit stack ──+ - name: Build and sign thin Linux AppImage+ id: package_linux+ if: matrix.platform == 'ubuntu-22.04'+ shell: bash+ env:+ ARTIFACT_PATHS: ${{ steps.build_linux.outputs.artifactPaths }}+ TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}+ TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}+ run: |+ set -euo pipefail+ deb_path="$(+ python3 - <<'PY'+ import json+ import os+ import pathlib+ import sys++ paths = json.loads(os.environ.get('ARTIFACT_PATHS', ''))+ matches = [pathlib.Path(path) for path in paths if str(path).endswith('.deb')]+ if len(matches) != 1 or not matches[0].is_file():+ sys.exit(f'Expected exactly one Linux deb artifact, got {matches}')+ print(matches[0])+ PY+ )"+ output_dir="studio/src-tauri/target/release/bundle/appimage"+ appimage="$output_dir/unsloth-studio_${APP_VERSION}_amd64.AppImage"+ export APPIMAGE_PATH="$appimage"+ studio/src-tauri/linux/build-thin-appimage.sh \+ "$deb_path" \+ "$RUNNER_TEMP/appimage-tools/appimagetool-x86_64.AppImage" \+ "$RUNNER_TEMP/appimage-tools/runtime-x86_64" \+ "$appimage"+ signature="${appimage}.sig"+ npx --prefix studio tauri signer sign "$appimage" > "$signature"+ if [[ ! -s "$signature" ]]; then+ echo "Tauri signer did not create a nonempty signature: $signature" >&2+ exit 1+ fi+ python3 - <<'PY'+ import json+ import os++ deb_paths = json.loads(os.environ['ARTIFACT_PATHS'])+ appimage = os.environ['APPIMAGE_PATH']+ paths = [*deb_paths, appimage, f'{appimage}.sig']+ with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as output:+ output.write(f'artifactPaths={json.dumps(paths)}\n')+ PY# ── macOS: build + sign + notarize ──- name: Build macOS app@@ -1139,7 +1203,7 @@ jobs:- name: Stage release assetsshell: bashenv:- ARTIFACT_PATHS: ${{ steps.build_linux.outputs.artifactPaths || steps.build_macos.outputs.artifactPaths || steps.build_windows.outputs.artifactPaths }}+ ARTIFACT_PATHS: ${{ steps.package_linux.outputs.artifactPaths || steps.build_macos.outputs.artifactPaths || steps.build_windows.outputs.artifactPaths }}run: |set -euo pipefailif command -v python3 >/dev/null 2>&1; thendiff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsxindex 3abc1c6c6b8..ff9a21339f0 100644--- a/studio/frontend/src/app/provider.tsx+++ b/studio/frontend/src/app/provider.tsx@@ -103,9 +103,9 @@ async function enforceMinimumWindowSize(const logicalWidth = Math.round(innerSize.width / scaleFactor);const logicalHeight = Math.round(innerSize.height / scaleFactor);- // Linux reports innerSize from a cache updated by configure events. The- // AppImage's bundled GTK can deliver that event after this check, leaving the- // old setup size in the cache even though the first app resize has completed.+ // Linux reports innerSize from a cache updated by WebKitGTK configure events.+ // That event can arrive after this check, leaving the old setup size in the+ // cache even though the first app resize has completed.const nextWidth = Math.max(logicalWidth,MIN_WINDOW_WIDTH,diff --git a/studio/src-tauri/linux/build-thin-appimage.sh b/studio/src-tauri/linux/build-thin-appimage.shnew file mode 100755index 00000000000..8399d44b11a--- /dev/null+++ b/studio/src-tauri/linux/build-thin-appimage.sh@@ -0,0 +1,181 @@+#!/usr/bin/env bash++set -euo pipefail++assert_thin_appdir() {+ local root="$1"+ local found=0+ local path++ while IFS= read -r -d '' path; do+ case "$(basename -- "$path")" in+ libglib-2.0.so*|libgobject-2.0.so*|libgio-2.0.so*|libgmodule-2.0.so*|\+ libgtk-3.so*|libgdk-3.so*|libgdk_pixbuf-2.0.so*|\+ libwebkit2gtk-4.1.so*|libjavascriptcoregtk-4.1.so*|libsoup-3.0.so*|\+ libcurl.so*|libcurl-gnutls.so*|libnghttp2.so*)+ echo "Thin AppImage unexpectedly contains host desktop library: $path" >&2+ found=1+ ;;+ esac+ done < <(find "$root" \( -type f -o -type l \) -print0)++ if [[ $found -ne 0 ]]; then+ return 1+ fi+}++stamp_appimage_bundle_type() {+ local binary_path="$1"++ python3 - "$binary_path" <<'PY'+import pathlib+import sys++binary_path = pathlib.Path(sys.argv[1])+deb_marker = b"__TAURI_BUNDLE_TYPE_VAR_DEB"+appimage_marker = b"__TAURI_BUNDLE_TYPE_VAR_APP"+binary = binary_path.read_bytes()++deb_count = binary.count(deb_marker)+appimage_count = binary.count(appimage_marker)+if deb_count != 1 or appimage_count != 0:+ sys.exit(+ f"Expected exactly one Tauri deb bundle marker and no AppImage marker in "+ f"{binary_path}; found deb={deb_count}, appimage={appimage_count}"+ )++binary_path.write_bytes(binary.replace(deb_marker, appimage_marker, 1))++stamped = binary_path.read_bytes()+if stamped.count(deb_marker) != 0 or stamped.count(appimage_marker) != 1:+ sys.exit(f"Failed to stamp the Tauri AppImage bundle marker in {binary_path}")+PY+}++# Keep the safety check directly executable so its behavior can be covered by+# a regression test without constructing a deb or downloading the toolchain.+if [[ $# -eq 2 && "$1" == "--verify-appdir" ]]; then+ assert_thin_appdir "$2"+ exit+fi++if [[ $# -ne 4 ]]; then+ echo "Usage: $0 DEB APPIMAGETOOL RUNTIME OUTPUT" >&2+ echo " $0 --verify-appdir APPDIR" >&2+ exit 2+fi++deb_path="$1"+appimagetool_path="$2"+runtime_path="$3"+output_path="$4"++for input_path in "$deb_path" "$appimagetool_path" "$runtime_path"; do+ if [[ ! -f "$input_path" ]]; then+ echo "Required AppImage input does not exist: $input_path" >&2+ exit 1+ fi+done++if [[ "$(dpkg-deb --field "$deb_path" Architecture)" != "amd64" ]]; then+ echo "The Linux AppImage must be built from an amd64 deb." >&2+ exit 1+fi++work_root="$(mktemp -d "${RUNNER_TEMP:-/tmp}/unsloth-thin-appimage.XXXXXX")"+trap 'rm -rf -- "$work_root"' EXIT+app_dir="$work_root/AppDir"+verify_dir="$work_root/verify"+output_dir="$(dirname -- "$output_path")"+mkdir -p "$app_dir" "$verify_dir" "$output_dir"+output_dir="$(CDPATH= cd -- "$output_dir" && pwd -P)"+output_path="$output_dir/$(basename -- "$output_path")"++# The deb is already a working host-integrated package. Reusing its payload+# avoids a partial GTK/WebKit dependency closure, which can mix an+# old bundled GLib with newer host GIO modules and network libraries.+dpkg-deb --extract "$deb_path" "$app_dir"++desktop_file="$app_dir/usr/share/applications/Unsloth.desktop"+icon_file="$app_dir/usr/share/icons/hicolor/128x128/apps/unsloth-studio.png"+binary_file="$app_dir/usr/bin/unsloth-studio"+for required_path in "$desktop_file" "$icon_file" "$binary_file"; do+ if [[ ! -f "$required_path" ]]; then+ echo "The deb is missing an AppImage input: $required_path" >&2+ exit 1+ fi+done++# tauri-bundler stamps the executable copied into a deb so the updater selects+# the deb installer. This executable is going into an AppImage instead, so+# stamp the equal-length AppImage marker before packaging it. Without this,+# the updater downloads the AppImage and then rejects it as an invalid deb.+stamp_appimage_bundle_type "$binary_file"++ln -s usr/share/applications/Unsloth.desktop "$app_dir/Unsloth.desktop"+ln -s usr/share/icons/hicolor/128x128/apps/unsloth-studio.png "$app_dir/unsloth-studio.png"+ln -s unsloth-studio.png "$app_dir/.DirIcon"++cat > "$app_dir/AppRun" <<'EOF'+#!/bin/sh+set -eu++appdir=${APPDIR:-$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)}+export PATH="$appdir/usr/bin${PATH:+:$PATH}"+export XDG_DATA_DIRS="$appdir/usr/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"++binary="$appdir/usr/bin/unsloth-studio"+missing=$(+ ldd "$binary" 2>/dev/null |+ sed -n 's/^[[:space:]]*\([^[:space:]]*\)[[:space:]]*=>[[:space:]]*not found.*$/\1/p'+)+if [ -n "$missing" ]; then+ message="Unsloth cannot start because required Linux libraries are missing:++$missing++On Ubuntu or Linux Mint, install them with:+sudo apt install libayatana-appindicator3-1 libwebkit2gtk-4.1-0 libgtk-3-0"+ printf '%s\n' "$message" >&2+ if command -v zenity >/dev/null 2>&1; then+ zenity --error --title="Unsloth cannot start" --text="$message" >/dev/null 2>&1 || true+ elif command -v xmessage >/dev/null 2>&1; then+ xmessage -center "$message" >/dev/null 2>&1 || true+ fi+ exit 127+fi++exec "$binary" "$@"+EOF+chmod +x "$app_dir/AppRun"++assert_thin_appdir "$app_dir"++ARCH=x86_64 "$appimagetool_path" --appimage-extract-and-run \+ --no-appstream \+ --runtime-file "$runtime_path" \+ "$app_dir" "$output_path"++if [[ ! -x "$output_path" ]]; then+ echo "appimagetool did not create an executable AppImage: $output_path" >&2+ exit 1+fi++(+ cd "$verify_dir"+ "$output_path" --appimage-extract >/dev/null+)+assert_thin_appdir "$verify_dir/squashfs-root"++if grep -q 'LD_LIBRARY_PATH' "$verify_dir/squashfs-root/AppRun"; then+ echo "Thin AppImage must not override the host library search path." >&2+ exit 1+fi++ldd_output="$(ldd "$verify_dir/squashfs-root/usr/bin/unsloth-studio")"+if grep -q 'not found' <<< "$ldd_output"; then+ echo "The AppImage binary has unresolved dependencies on the build host." >&2+ exit 1+fi++echo "Built thin AppImage: $output_path"diff --git a/studio/src-tauri/src/commands.rs b/studio/src-tauri/src/commands.rsindex 1fd26b77be5..170b7327297 100644--- a/studio/src-tauri/src/commands.rs+++ b/studio/src-tauri/src/commands.rs@@ -125,15 +125,6 @@ pub async fn check_install_status() -> bool {cmd.creation_flags(crate::process::CREATE_NO_WINDOW);}- // Match the same AppImage env clearing used in process.rs and install.rs,- // otherwise the probe can fail due to bundled libs even when the install is fine.- #[cfg(target_os = "linux")]- if std::env::var_os("APPIMAGE").is_some() {- cmd.env_remove("LD_LIBRARY_PATH");- cmd.env_remove("PYTHONHOME");- cmd.env_remove("PYTHONPATH");- }-// Tauri uses the legacy root regardless of UNSLOTH_STUDIO_HOME / STUDIO_HOME;// probe subprocesses must follow the same isolation as process.rs.cmd.env_remove("UNSLOTH_STUDIO_HOME");diff --git a/studio/src-tauri/src/desktop_auth.rs b/studio/src-tauri/src/desktop_auth.rsindex abfc2175488..32e777d1b6f 100644--- a/studio/src-tauri/src/desktop_auth.rs+++ b/studio/src-tauri/src/desktop_auth.rs@@ -230,13 +230,6 @@ async fn provision_desktop_auth() -> Result<(), String> {cmd.args(["studio", "provision-desktop-auth"]).stdout(std::process::Stdio::null()).stderr(std::process::Stdio::piped());- #[cfg(target_os = "linux")]- if std::env::var_os("APPIMAGE").is_some() {- cmd.env_remove("LD_LIBRARY_PATH");- cmd.env_remove("PYTHONHOME");- cmd.env_remove("PYTHONPATH");- }-// Tauri uses the legacy root regardless of UNSLOTH_STUDIO_HOME / STUDIO_HOME.// Scrub so provisioning writes match what the Rust auth code reads.cmd.env_remove("UNSLOTH_STUDIO_HOME");diff --git a/studio/src-tauri/src/install.rs b/studio/src-tauri/src/install.rsindex 64bee7a3c24..25b990f7b40 100644--- a/studio/src-tauri/src/install.rs+++ b/studio/src-tauri/src/install.rs@@ -426,16 +426,6 @@ fn spawn_script(.stdout(Stdio::piped()).stderr(Stdio::piped());- // AppImage sets LD_LIBRARY_PATH to its bundled libs, which breaks Python- // spawned by the install script. Only clear inside AppImage — native installs- // may need these for custom CUDA or conda paths.- #[cfg(target_os = "linux")]- if std::env::var_os("APPIMAGE").is_some() {- cmd.env_remove("LD_LIBRARY_PATH");- cmd.env_remove("PYTHONHOME");- cmd.env_remove("PYTHONPATH");- }-// Tauri only does default-root installs; install.sh / install.ps1 reject// these under --tauri. Scrub so an inherited value can't trip the guard.cmd.env_remove("UNSLOTH_STUDIO_HOME");diff --git a/studio/src-tauri/src/preflight/managed.rs b/studio/src-tauri/src/preflight/managed.rsindex e9c651c9b21..b43e5936572 100644--- a/studio/src-tauri/src/preflight/managed.rs+++ b/studio/src-tauri/src/preflight/managed.rs@@ -307,13 +307,6 @@ async fn run_cli_probe(bin: &Path, args: &[&str]) -> bool {let mut cmd = Command::new(bin);cmd.args(args).stdout(Stdio::null()).stderr(Stdio::null());- #[cfg(target_os = "linux")]- if std::env::var_os("APPIMAGE").is_some() {- cmd.env_remove("LD_LIBRARY_PATH");- cmd.env_remove("PYTHONHOME");- cmd.env_remove("PYTHONPATH");- }-// Tauri uses the legacy root regardless of UNSLOTH_STUDIO_HOME / STUDIO_HOME;// probe subprocesses must follow the same isolation as process.rs.cmd.env_remove("UNSLOTH_STUDIO_HOME");@@ -358,13 +351,6 @@ async fn probe_cli_capability(bin: &Path) -> Option<DesktopCapability> {.stdout(Stdio::piped()).stderr(Stdio::null());- #[cfg(target_os = "linux")]- if std::env::var_os("APPIMAGE").is_some() {- cmd.env_remove("LD_LIBRARY_PATH");- cmd.env_remove("PYTHONHOME");- cmd.env_remove("PYTHONPATH");- }-// Tauri uses the legacy root regardless of UNSLOTH_STUDIO_HOME / STUDIO_HOME;// probe subprocesses must follow the same isolation as process.rs.cmd.env_remove("UNSLOTH_STUDIO_HOME");diff --git a/studio/src-tauri/src/process.rs b/studio/src-tauri/src/process.rsindex dad97db573c..037c252464b 100644--- a/studio/src-tauri/src/process.rs+++ b/studio/src-tauri/src/process.rs@@ -600,17 +600,6 @@ pub fn start_backend();}- // AppImage sets LD_LIBRARY_PATH to its bundled libs, which breaks the spawned- // Python process (wrong libpython/libz → "No module named encodings").- // Only clear when running inside an AppImage — native package installs may- // need these env vars for custom CUDA or conda paths.- #[cfg(target_os = "linux")]- if std::env::var_os("APPIMAGE").is_some() {- cmd.env_remove("LD_LIBRARY_PATH");- cmd.env_remove("PYTHONHOME");- cmd.env_remove("PYTHONPATH");- }-// Tauri uses the legacy root regardless of UNSLOTH_STUDIO_HOME / STUDIO_HOME;// scrub so the spawned Python backend can't diverge. UNSLOTH_LLAMA_CPP_PATH// is a pre-existing user-controlled llama.cpp dir override; keep it.diff --git a/studio/src-tauri/src/update.rs b/studio/src-tauri/src/update.rsindex ff3872163d0..d5b11c14052 100644--- a/studio/src-tauri/src/update.rs+++ b/studio/src-tauri/src/update.rs@@ -85,14 +85,6 @@ fn spawn_update(let mut cmd = build_update_command(bin)?;cmd.stdout(Stdio::piped()).stderr(Stdio::piped());- // AppImage sets LD_LIBRARY_PATH to its bundled libs, which breaks Python- #[cfg(target_os = "linux")]- if std::env::var_os("APPIMAGE").is_some() {- cmd.env_remove("LD_LIBRARY_PATH");- cmd.env_remove("PYTHONHOME");- cmd.env_remove("PYTHONPATH");- }-// Tauri manages the legacy root; scrub so 'unsloth studio update' targets// the same install the desktop app uses, not an inherited custom root.cmd.env_remove("UNSLOTH_STUDIO_HOME");diff --git a/studio/src-tauri/tauri.conf.json b/studio/src-tauri/tauri.conf.jsonindex 3b36ec93d71..08e9e3fa2d2 100644--- a/studio/src-tauri/tauri.conf.json+++ b/studio/src-tauri/tauri.conf.json@@ -57,7 +57,7 @@"homepage": "https://unsloth.ai/","copyright": "© 2026 Unsloth AI. All rights reserved.","license": "AGPL-3.0-only",- "targets": ["app", "appimage", "deb", "dmg", "nsis"],+ "targets": ["app", "deb", "dmg", "nsis"],"resources": {"../../install.sh": "install.sh","../../install.ps1": "install.ps1"@@ -85,9 +85,6 @@}},"linux": {- "appimage": {- "bundleMediaFramework": false- },"deb": {"desktopTemplate": "./linux/unsloth.desktop","provides": ["unsloth-studio-desktop"],diff --git a/tests/security/test_release_desktop_appimage.py b/tests/security/test_release_desktop_appimage.pynew file mode 100644index 00000000000..4e6ca314fde--- /dev/null+++ b/tests/security/test_release_desktop_appimage.py@@ -0,0 +1,246 @@+"""Contracts for the host-integrated Linux AppImage release path."""++import os+import shutil+import subprocess+from pathlib import Path++import yaml+++REPO_ROOT = Path(__file__).resolve().parents[2]+WORKFLOW = REPO_ROOT / ".github" / "workflows" / "release-desktop.yml"+PACKAGER = REPO_ROOT / "studio" / "src-tauri" / "linux" / "build-thin-appimage.sh"+++def _workflow():+ return yaml.safe_load(WORKFLOW.read_text(encoding = "utf-8"))+++def _step(name: str):+ steps = _workflow()["jobs"]["build"]["steps"]+ return next(step for step in steps if step.get("name") == name)+++def test_release_pins_the_appimage_builder_and_runtime_by_digest():+ step = _step("Pin thin AppImage toolchain")+ assert step["if"] == "matrix.platform == 'ubuntu-22.04'"+ assert "/AppImage/appimagetool/releases/download/1.9.1/" in step["env"]["APPIMAGETOOL_URL"]+ assert len(step["env"]["APPIMAGETOOL_SHA256"]) == 64+ assert (+ "/AppImage/type2-runtime/releases/download/20251108/" in step["env"]["APPIMAGE_RUNTIME_URL"]+ )+ assert len(step["env"]["APPIMAGE_RUNTIME_SHA256"]) == 64+ assert step["run"].count("sha256sum -c") == 2+++def test_linux_build_repackages_the_deb_and_signs_the_final_appimage():+ build = _step("Build Linux deb")+ package = _step("Build and sign thin Linux AppImage")+ stage = _step("Stage release assets")++ assert "--bundles deb" in build["with"]["args"]+ assert '"createUpdaterArtifacts":false' in build["with"]["args"]+ assert "TAURI_SIGNING_PRIVATE_KEY" not in build.get("env", {})+ assert "build-thin-appimage.sh" in package["run"]+ assert 'tauri signer sign "$appimage" > "$signature"' in package["run"]+ assert '[[ ! -s "$signature" ]]' in package["run"]+ assert "f'{appimage}.sig'" in package["run"]+ assert package["env"]["ARTIFACT_PATHS"] == "${{ steps.build_linux.outputs.artifactPaths }}"+ assert stage["env"]["ARTIFACT_PATHS"].startswith(+ "${{ steps.package_linux.outputs.artifactPaths"+ )+++def test_tauri_cannot_build_the_old_bundled_appimage():+ config = yaml.safe_load(+ (REPO_ROOT / "studio" / "src-tauri" / "tauri.conf.json").read_text(encoding = "utf-8")+ )+ assert "appimage" not in config["bundle"]["targets"]+ assert "appimage" not in config["bundle"]["linux"]+++def test_thin_appimage_never_injects_a_partial_desktop_runtime():+ script = PACKAGER.read_text(encoding = "utf-8")+ assert "dpkg-deb --extract" in script+ assert "--runtime-file" in script+ assert "linuxdeploy" not in script+ assert "export LD_LIBRARY_PATH" not in script+ for library in (+ "libglib-2.0.so",+ "libgio-2.0.so",+ "libgtk-3.so",+ "libwebkit2gtk-4.1.so",+ "libcurl.so",+ "libnghttp2.so",+ ):+ assert library in script+ assert "sudo apt install libayatana-appindicator3-1 libwebkit2gtk-4.1-0 libgtk-3-0" in script+ assert "zenity --error" in script+ assert "xmessage -center" in script+++def test_thin_appimage_rejects_a_bundled_host_library(tmp_path):+ allowed = tmp_path / "allowed"+ allowed.mkdir()+ (allowed / "libunsloth-test.so").touch()+ subprocess.run(+ [PACKAGER, "--verify-appdir", allowed],+ check = True,+ capture_output = True,+ text = True,+ )++ forbidden = tmp_path / "forbidden"+ forbidden.mkdir()+ (forbidden / "libglib-2.0.so.0").touch()+ result = subprocess.run(+ [PACKAGER, "--verify-appdir", forbidden],+ check = False,+ capture_output = True,+ text = True,+ )++ assert result.returncode != 0+ assert "libglib-2.0.so.0" in result.stderr+++def _build_fake_appimage(+ tmp_path,+ *,+ bundle_markers = 1,+ check = True,+):+ package_root = tmp_path / "package"+ control_dir = package_root / "DEBIAN"+ binary_dir = package_root / "usr" / "bin"+ desktop_dir = package_root / "usr" / "share" / "applications"+ icon_dir = package_root / "usr" / "share" / "icons" / "hicolor" / "128x128" / "apps"+ for directory in (control_dir, binary_dir, desktop_dir, icon_dir):+ directory.mkdir(parents = True, exist_ok = True)++ (control_dir / "control").write_text(+ "Package: unsloth-test\nVersion: 1.0\nArchitecture: amd64\nDescription: test\n",+ encoding = "utf-8",+ )+ shutil.copy2("/bin/sh", binary_dir / "unsloth-studio")+ with (binary_dir / "unsloth-studio").open("ab") as binary:+ binary.write(b"__TAURI_BUNDLE_TYPE_VAR_DEB" * bundle_markers)+ (desktop_dir / "Unsloth.desktop").write_text("[Desktop Entry]\n", encoding = "utf-8")+ (icon_dir / "unsloth-studio.png").write_bytes(b"test")++ deb_path = tmp_path / "unsloth-test.deb"+ subprocess.run(+ ["dpkg-deb", "--build", "--root-owner-group", package_root, deb_path],+ check = True,+ capture_output = True,+ text = True,+ )++ appimagetool = tmp_path / "appimagetool"+ appimagetool.write_text(+ """#!/usr/bin/env bash+set -euo pipefail+while [[ $# -gt 2 ]]; do shift; done+app_dir="$1"+output_path="$2"+captured_app_dir="${output_path}.AppDir"+cp -a "$app_dir" "$captured_app_dir"+printf '#!/usr/bin/env bash\nset -euo pipefail\ncp -a %q squashfs-root\n' "$captured_app_dir" > "$output_path"+chmod +x "$output_path"+""",+ encoding = "utf-8",+ )+ appimagetool.chmod(0o755)+ runtime = tmp_path / "runtime"+ runtime.touch()++ relative_output = Path("artifacts") / "unsloth-test.AppImage"+ result = subprocess.run(+ [PACKAGER, deb_path, appimagetool, runtime, relative_output],+ cwd = tmp_path,+ check = check,+ capture_output = True,+ text = True,+ )++ output_path = tmp_path / relative_output+ return output_path, Path(f"{output_path}.AppDir"), result+++def test_thin_appimage_resolves_a_relative_output_before_verification(tmp_path):+ output_path, _, result = _build_fake_appimage(tmp_path)++ assert output_path.is_file()+ assert f"Built thin AppImage: {output_path}" in result.stdout+++def test_thin_appimage_stamps_the_copied_deb_binary_as_an_appimage(tmp_path):+ _, app_dir, _ = _build_fake_appimage(tmp_path)+ binary = (app_dir / "usr" / "bin" / "unsloth-studio").read_bytes()++ assert b"__TAURI_BUNDLE_TYPE_VAR_DEB" not in binary+ assert binary.count(b"__TAURI_BUNDLE_TYPE_VAR_APP") == 1+++def test_thin_appimage_rejects_an_unexpected_tauri_bundle_marker(tmp_path):+ for bundle_markers in (0, 2):+ _, _, result = _build_fake_appimage(+ tmp_path / str(bundle_markers),+ bundle_markers = bundle_markers,+ check = False,+ )++ assert result.returncode != 0+ assert "Expected exactly one Tauri deb bundle marker" in result.stderr+++def test_thin_appimage_preserves_host_xdg_data_dirs(tmp_path):+ _, app_dir, _ = _build_fake_appimage(tmp_path)+ apprun = app_dir / "AppRun"+ command = [apprun, "-c", 'printf %s "$XDG_DATA_DIRS"']++ default_env = os.environ.copy()+ default_env.pop("XDG_DATA_DIRS", None)+ default_result = subprocess.run(+ command,+ env = default_env,+ check = True,+ capture_output = True,+ text = True,+ )+ assert default_result.stdout == f"{app_dir}/usr/share:/usr/local/share:/usr/share"++ custom_env = {**default_env, "XDG_DATA_DIRS": "/opt/share:/srv/share"}+ custom_result = subprocess.run(+ command,+ env = custom_env,+ check = True,+ capture_output = True,+ text = True,+ )+ assert custom_result.stdout == f"{app_dir}/usr/share:/opt/share:/srv/share"+++def test_release_notes_keep_existing_appimage_guidance():+ notes = _workflow()["env"]["DESKTOP_RELEASE_NOTES"]+ assert "`.AppImage` is experimental." in notes+ assert "libwebkit2gtk" not in notes+ assert "Linux AppImage on Ubuntu 24.04+ may require: `sudo apt install libfuse2t64`" in notes+ assert "--appimage-extract-and-run" not in notes+++def test_thin_appimage_preserves_user_runtime_environment_for_child_processes():+ source_root = REPO_ROOT / "studio" / "src-tauri" / "src"+ child_process_sources = (+ source_root / "commands.rs",+ source_root / "desktop_auth.rs",+ source_root / "install.rs",+ source_root / "preflight" / "managed.rs",+ source_root / "process.rs",+ source_root / "update.rs",+ )++ for source_path in child_process_sources:+ source = source_path.read_text(encoding = "utf-8")+ assert 'var_os("APPIMAGE")' not in source, source_path