Skip to content

Personal AI, On Personal Devices

Python

feat(desktop): add Windows ARM64 builds to the existing Tauri app (#1160)

Elliot Slusky90a2a27f916d
diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml
index 245f4e28..0d4e61ed 100644
--- a/.github/workflows/desktop.yml
+++ b/.github/workflows/desktop.yml
@@ -9,6 +9,9 @@ on:
branches: [main]
paths:
- 'frontend/**'
+ - 'rust/**'
+ - 'pyproject.toml'
+ - 'uv.lock'
- '.github/workflows/desktop.yml'
workflow_dispatch:
inputs:
@@ -27,6 +30,95 @@ permissions:
contents: write
jobs:
+ # Build an unsigned test installer on PRs; this job never publishes releases
+ # or uses signing credentials. Exercise the existing x64 backend on ARM too.
+ test-windows-arm64:
+ if: github.event_name == 'pull_request'
+ runs-on: windows-11-arm
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@v7
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v7
+ with:
+ node-version: '22'
+
+ - name: Use the reviewed npm toolchain
+ run: npm install --global [email protected]
+
+ - name: Install frontend dependencies
+ working-directory: frontend
+ run: npm ci
+
+ - name: Install Rust stable
+ uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: x86_64-pc-windows-msvc
+
+ - name: Rust cache
+ uses: swatinem/rust-cache@v2
+ with:
+ workspaces: |
+ frontend/src-tauri -> target
+ rust -> target
+
+ - name: Install uv
+ uses: astral-sh/[email protected]
+ with:
+ enable-cache: true
+
+ - name: Verify existing backend on Windows ARM64
+ shell: bash
+ env:
+ UV_PYTHON: cpython-3.12-windows-x86_64-none
+ CARGO_BUILD_TARGET: x86_64-pc-windows-msvc
+ RUSTUP_TOOLCHAIN: stable
+ PYO3_CROSS_PYTHON_VERSION: '3.12'
+ PYO3_CROSS_PYTHON_IMPLEMENTATION: CPython
+ run: |
+ uv sync --locked --extra dev --extra desktop --extra inference-cloud --extra inference-google --group desktop-native
+ uv run python -c "import sysconfig, openjarvis_rust; assert sysconfig.get_platform() == 'win-amd64'; print('x64 backend and Rust extension import OK')"
+ uv run jarvis --version
+ uv run pytest tests/hardware/test_hardware_profiles.py tests/core/test_utils.py -q
+
+ - name: Download ARM64 Ollama and stage test bundle
+ shell: bash
+ run: |
+ frontend/src-tauri/scripts/download-ollama.sh aarch64-pc-windows-msvc
+ node <<'NODE'
+ const { writeFileSync } = require('node:fs');
+ writeFileSync('frontend/src-tauri/tauri.arm64-test.conf.json', JSON.stringify({
+ bundle: {
+ targets: ['nsis'],
+ externalBin: ['binaries/ollama'],
+ resources: { 'binaries/ollama-runtime-aarch64-pc-windows-msvc/': './' },
+ },
+ }));
+ NODE
+
+ - name: Build ARM64 test installer
+ working-directory: frontend
+ run: npx tauri build --target aarch64-pc-windows-msvc --bundles nsis --config src-tauri/tauri.arm64-test.conf.json
+
+ - name: Verify native ARM64 executables
+ shell: bash
+ run: |
+ node frontend/src-tauri/scripts/verify-arm64-pe.mjs \
+ frontend/src-tauri/target/aarch64-pc-windows-msvc/release/openjarvis-desktop.exe \
+ frontend/src-tauri/binaries/ollama-aarch64-pc-windows-msvc.exe \
+ frontend/src-tauri/binaries/ollama-runtime-aarch64-pc-windows-msvc/lib/ollama/llama-server.exe
+ frontend/src-tauri/binaries/ollama-aarch64-pc-windows-msvc.exe --version
+ frontend/src-tauri/binaries/ollama-runtime-aarch64-pc-windows-msvc/lib/ollama/llama-server.exe --version
+
+ - name: Upload ARM64 test installer
+ uses: actions/upload-artifact@v7
+ with:
+ name: windows-arm64-test-installer
+ path: frontend/src-tauri/target/aarch64-pc-windows-msvc/release/bundle/nsis/**/*.exe
+ if-no-files-found: error
+
validate:
runs-on: ubuntu-22.04
@@ -136,6 +228,12 @@ jobs:
args: '--target universal-apple-darwin'
- platform: windows-latest
args: ''
+ target: x86_64-pc-windows-msvc
+ updater-platform: windows-x86_64
+ - platform: windows-11-arm
+ args: '--target aarch64-pc-windows-msvc --bundles nsis'
+ target: aarch64-pc-windows-msvc
+ updater-platform: windows-aarch64
runs-on: ${{ matrix.platform }}
@@ -282,6 +380,8 @@ jobs:
- name: Download Ollama sidecar
shell: bash
+ env:
+ OLLAMA_TARGET: ${{ matrix.target }}
run: |
cd frontend/src-tauri/scripts && chmod +x download-ollama.sh
if [[ "${{ matrix.platform }}" == "macos-14" ]]; then
@@ -302,7 +402,7 @@ jobs:
fi
done
else
- ./download-ollama.sh
+ ./download-ollama.sh "$OLLAMA_TARGET"
fi
- name: Determine release info
@@ -382,6 +482,7 @@ jobs:
shell: bash
env:
TAURI_VERSION: ${{ steps.release-info.outputs.tauri_version }}
+ OLLAMA_TARGET: ${{ matrix.target }}
run: |
# The CLI and tauri-action both read --config. An environment-only
# TAURI_CONFIG override leaves the action's version at tauri.conf.json.
@@ -391,13 +492,17 @@ jobs:
assert.match(process.env.TAURI_VERSION,
/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,
'Tauri release version must be SemVer');
- writeFileSync('frontend/src-tauri/tauri.release.conf.json', JSON.stringify({
+ const config = {
version: process.env.TAURI_VERSION,
bundle: {
createUpdaterArtifacts: true,
externalBin: ['binaries/ollama'],
},
- }));
+ };
+ if (process.env.OLLAMA_TARGET === 'aarch64-pc-windows-msvc') {
+ config.bundle.resources = { 'binaries/ollama-runtime-aarch64-pc-windows-msvc/': './' };
+ }
+ writeFileSync('frontend/src-tauri/tauri.release.conf.json', JSON.stringify(config));
NODE
- name: Configure Apple signing
@@ -456,6 +561,7 @@ jobs:
EXPECTED_VERSION: ${{ steps.release-info.outputs.tauri_version }}
BUILT_VERSION: ${{ steps.tauri-build.outputs.appVersion }}
ARTIFACT_PATHS: ${{ steps.tauri-build.outputs.artifactPaths }}
+ EXPECTED_UPDATER_PLATFORM: ${{ matrix.updater-platform }}
run: |
node <<'NODE'
const assert = require('node:assert/strict');
@@ -474,12 +580,22 @@ jobs:
assert.ok(existsSync('latest.json'), 'tauri-action did not generate latest.json');
const latest = JSON.parse(readFileSync('latest.json', 'utf8'));
assert.equal(latest.version, expected, 'latest.json version');
- const prefix = { Linux: 'linux-', macOS: 'darwin-', Windows: 'windows-' }[process.env.RUNNER_OS];
+ const prefix = process.env.EXPECTED_UPDATER_PLATFORM ||
+ { Linux: 'linux-', macOS: 'darwin-' }[process.env.RUNNER_OS];
assert.ok(Object.entries(latest.platforms || {}).some(([platform, entry]) =>
platform.startsWith(prefix) && entry.signature?.trim() && entry.url),
`No signed ${process.env.RUNNER_OS} updater in latest.json`);
NODE
+ - name: Verify native ARM64 release executables
+ if: matrix.platform == 'windows-11-arm'
+ shell: bash
+ run: |
+ node frontend/src-tauri/scripts/verify-arm64-pe.mjs \
+ frontend/src-tauri/target/aarch64-pc-windows-msvc/release/openjarvis-desktop.exe \
+ frontend/src-tauri/binaries/ollama-aarch64-pc-windows-msvc.exe \
+ frontend/src-tauri/binaries/ollama-runtime-aarch64-pc-windows-msvc/lib/ollama/llama-server.exe
+
verify-release:
needs: [build-and-release]
runs-on: ubuntu-latest
@@ -515,7 +631,7 @@ jobs:
const assetsByUrl = new Map(assets.map(asset => [asset.url, asset]));
const assetsByName = new Map(assets.map(asset => [asset.name, asset]));
assert.equal(latest.version, process.env.EXPECTED_VERSION);
- for (const platform of ['darwin-aarch64', 'darwin-x86_64', 'linux-x86_64', 'windows-x86_64']) {
+ for (const platform of ['darwin-aarch64', 'darwin-x86_64', 'linux-x86_64', 'windows-x86_64', 'windows-aarch64']) {
const entry = latest.platforms?.[platform];
assert.ok(entry?.signature?.trim() && entry?.url, `Missing signed updater for ${platform}`);
const asset = assetsByUrl.get(entry.url);
diff --git a/docs/desktop-auto-update.md b/docs/desktop-auto-update.md
index 5b320324..c9bcd0ff 100644
--- a/docs/desktop-auto-update.md
+++ b/docs/desktop-auto-update.md
@@ -29,6 +29,11 @@ the Tauri wiring is in
[`frontend/src-tauri/tauri.conf.json`](../frontend/src-tauri/tauri.conf.json)
under `plugins.updater`.
+Windows ARM64 releases use an NSIS `arm64-setup.exe` installer, with a separate
+`windows-aarch64` updater entry. Windows x64 keeps its `windows-x86_64` entry.
+Release verification requires both entries and their matching signature assets,
+so an ARM64 app cannot be offered an x64 package by the release manifest.
+
## How releases reach the update endpoint
The `Desktop Build & Release` GitHub Action
diff --git a/docs/getting-started/windows-native.md b/docs/getting-started/windows-native.md
index 36ad1085..1b9f02c4 100644
--- a/docs/getting-started/windows-native.md
+++ b/docs/getting-started/windows-native.md
@@ -5,6 +5,61 @@ Phase-1 of the native-Windows-support RFC (#298). Mirrors the Linux
WSL2 or Docker. Choose this over [WSL2](wsl2.md) only if you want to
avoid a Linux VM; WSL2 remains the smoother experience for most users.
+## Windows ARM64 desktop
+
+The existing Tauri/React desktop app can be built for Windows 11 on ARM.
+The desktop release workflow produces an `arm64-setup.exe` NSIS installer and
+adds `windows-aarch64` to the updater manifest alongside the x64 build. Use
+the ARM64 installer when it appears in a new desktop release; older releases
+only include x64 installers.
+
+This uses the same UI, backend, and Ollama integration as the other desktop
+builds. The desktop executable and bundled Ollama are ARM64. The current
+Python dependency stack has no Windows ARM64 wheels for several packages,
+including the locked NumPy, PyArrow, and speech dependencies. The app
+therefore selects uv-managed **x64 CPython 3.12** and builds the Rust Python
+extension for x64; Windows runs that backend through x64 emulation. This
+preserves the existing features without a separate UI or dependency stack.
+
+First-launch prerequisites are the same as the x64 desktop: Git, uv, Rust,
+and Visual Studio Build Tools with the **x64 C++ workload**. With an ARM64
+Rust installation, install the x64 target for stable Rust:
+
+```powershell
+rustup target add --toolchain stable x86_64-pc-windows-msvc
+```
+
+The ARM64 app uses stable Rust for backend builds so the compiler matches the
+installed x64 target, rather than selecting a separate minimum-version toolchain.
+It also supplies PyO3's cross-compilation settings for x64 CPython 3.12.
+The Python extension still targets x64. The ARM64 desktop build itself requires the
+ARM64 C++ build tools and Clang (the Visual Studio **C++ Clang tools for Windows**
+component, with `clang.exe` on PATH). Setup still requires the user's
+inference-source choice before starting local inference or downloading a model.
+
+### Testing without a Windows ARM laptop
+
+The desktop workflow's `test-windows-arm64` PR job runs on GitHub's
+`windows-11-arm` runner. It checks backend imports and CLI startup under x64
+emulation, builds an unsigned NSIS installer, checks that the desktop and
+Ollama executable headers identify ARM64, and uploads the
+`windows-arm64-test-installer` artifact. Passing this job verifies the build
+and dependency path; it does not verify interactive chat or hardware acceleration.
+
+For an interactive test, use Windows 11 ARM in UTM, Parallels, or VMware Fusion
+on an Apple silicon Mac. Download the installer artifact from the PR's Actions
+run, then check:
+
+1. Settings → System → About identifies an ARM-based processor.
+2. The installer completes and OpenJarvis launches.
+3. Local setup completes with a small model; chat streams and Stop cancels.
+4. Settings, conversation history, and relaunch work as on the x64 app.
+5. In Task Manager's Details tab, enable the Architecture column: the desktop
+ and Ollama are ARM64, while Python is x64.
+
+A VM is useful for compatibility testing; it does not validate GPU/NPU
+performance on physical Windows ARM hardware.
+
## What you get
- A PowerShell installer that probes prerequisites, installs `uv`,
diff --git a/frontend/src-tauri/scripts/download-ollama.sh b/frontend/src-tauri/scripts/download-ollama.sh
index bbc4adf1..f603e8b6 100755
--- a/frontend/src-tauri/scripts/download-ollama.sh
+++ b/frontend/src-tauri/scripts/download-ollama.sh
@@ -9,6 +9,7 @@
# ./download-ollama.sh aarch64-apple-darwin
# ./download-ollama.sh universal-apple-darwin
# ./download-ollama.sh x86_64-unknown-linux-gnu
+# ./download-ollama.sh aarch64-pc-windows-msvc
#
# Ollama distributes platform binaries as archives (.tgz / .tar.zst).
# This script downloads, extracts the `ollama` CLI binary, renames it
@@ -42,7 +43,12 @@ else
esac
;;
MINGW*|MSYS*|CYGWIN*|Windows_NT)
- TARGET="x86_64-pc-windows-msvc"
+ # Git Bash can report x86_64 when running under emulation on ARM.
+ case "${PROCESSOR_ARCHITEW6432:-${PROCESSOR_ARCHITECTURE:-$ARCH}}" in
+ ARM64|arm64|aarch64) TARGET="aarch64-pc-windows-msvc" ;;
+ AMD64|amd64|x86_64) TARGET="x86_64-pc-windows-msvc" ;;
+ *) echo "Unsupported Windows arch: $ARCH"; exit 1 ;;
+ esac
;;
*)
echo "Unsupported OS: $OS"; exit 1 ;;
@@ -57,8 +63,10 @@ case "$TARGET" in
*windows*) SUFFIX=".exe" ;;
esac
OUT_FILE="$BINARIES_DIR/ollama-${TARGET}${SUFFIX}"
+RUNTIME_DIR="$BINARIES_DIR/ollama-runtime-${TARGET}"
-if [ -f "$OUT_FILE" ]; then
+# ARM64 inference also needs the archive's DLLs and lib/ollama runners.
+if [ -f "$OUT_FILE" ] && { [ "$TARGET" != "aarch64-pc-windows-msvc" ] || [ -d "$RUNTIME_DIR/lib/ollama" ]; }; then
echo "Already exists: $OUT_FILE"
echo "Delete it first to re-download."
exit 0
@@ -84,41 +92,45 @@ case "$TARGET" in
ASSET_URL="${RELEASE_URL}/ollama-windows-amd64.zip"
ARCHIVE_TYPE="zip"
;;
+ aarch64-pc-windows-msvc)
+ ASSET_URL="${RELEASE_URL}/ollama-windows-arm64.zip"
+ ARCHIVE_TYPE="zip"
+ ;;
*)
echo "No Ollama binary mapping for target: $TARGET"
exit 1
;;
esac
-TMPDIR="$(mktemp -d)"
-trap 'rm -rf "$TMPDIR"' EXIT
+OLLAMA_TMP_DIR="$(mktemp -d)"
+trap 'rm -rf "$OLLAMA_TMP_DIR"' EXIT
echo "Downloading: $ASSET_URL"
-ARCHIVE_FILE="$TMPDIR/ollama-archive"
+ARCHIVE_FILE="$OLLAMA_TMP_DIR/ollama-archive"
curl -fSL --progress-bar "$ASSET_URL" -o "$ARCHIVE_FILE"
echo "Extracting..."
case "$ARCHIVE_TYPE" in
tgz)
- tar xzf "$ARCHIVE_FILE" -C "$TMPDIR"
+ tar xzf "$ARCHIVE_FILE" -C "$OLLAMA_TMP_DIR"
;;
zst)
if command -v zstd &>/dev/null; then
- zstd -d "$ARCHIVE_FILE" -o "$TMPDIR/ollama.tar" --quiet
- tar xf "$TMPDIR/ollama.tar" -C "$TMPDIR"
+ zstd -d "$ARCHIVE_FILE" -o "$OLLAMA_TMP_DIR/ollama.tar" --quiet
+ tar xf "$OLLAMA_TMP_DIR/ollama.tar" -C "$OLLAMA_TMP_DIR"
else
echo "zstd not found. Install with: brew install zstd (macOS) or apt install zstd (Linux)"
exit 1
fi
;;
zip)
- unzip -q "$ARCHIVE_FILE" -d "$TMPDIR"
+ unzip -q "$ARCHIVE_FILE" -d "$OLLAMA_TMP_DIR"
;;
esac
# Find the ollama binary in the extracted contents
OLLAMA_BIN=""
-for candidate in "$TMPDIR/bin/ollama" "$TMPDIR/ollama" "$TMPDIR/ollama.exe"; do
+for candidate in "$OLLAMA_TMP_DIR/bin/ollama" "$OLLAMA_TMP_DIR/ollama" "$OLLAMA_TMP_DIR/ollama.exe"; do
if [ -f "$candidate" ]; then
OLLAMA_BIN="$candidate"
break
@@ -127,7 +139,7 @@ done
if [ -z "$OLLAMA_BIN" ]; then
echo "Could not find ollama binary in archive. Contents:"
- find "$TMPDIR" -type f | head -20
+ find "$OLLAMA_TMP_DIR" -type f | head -20
exit 1
fi
@@ -139,6 +151,23 @@ if [ "$TARGET" = "universal-apple-darwin" ]; then
fi
fi
+if [ "$TARGET" = "aarch64-pc-windows-msvc" ]; then
+ if [ ! -d "$OLLAMA_TMP_DIR/lib/ollama" ]; then
+ echo "Windows Ollama archive is missing its lib/ollama inference runtime"
+ exit 1
+ fi
+ # Preserve the release layout beside the renamed sidecar. The release
+ # config maps this directory beside the installed ollama.exe.
+ rm -rf "$RUNTIME_DIR"
+ mkdir -p "$RUNTIME_DIR"
+ for resource in "$OLLAMA_TMP_DIR"/*; do
+ case "$(basename "$resource")" in
+ ollama.exe|ollama-archive) continue ;;
+ esac
+ cp -R "$resource" "$RUNTIME_DIR/"
+ done
+fi
+
cp "$OLLAMA_BIN" "$OUT_FILE"
chmod +x "$OUT_FILE"
diff --git a/frontend/src-tauri/scripts/verify-arm64-pe.mjs b/frontend/src-tauri/scripts/verify-arm64-pe.mjs
new file mode 100644
index 00000000..60a3dcd8
--- /dev/null
+++ b/frontend/src-tauri/scripts/verify-arm64-pe.mjs
@@ -0,0 +1,15 @@
+// Fail packaging if an x64 executable was accidentally staged as ARM64.
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+
+assert.ok(process.argv.length > 2, 'Pass at least one Windows executable');
+for (const path of process.argv.slice(2)) {
+ const bytes = readFileSync(path);
+ assert.ok(bytes.length >= 64, `${path}: truncated DOS header`);
+ assert.equal(bytes.toString('ascii', 0, 2), 'MZ', `${path}: missing DOS signature`);
+ const offset = bytes.readUInt32LE(0x3c);
+ assert.ok(offset + 6 <= bytes.length, `${path}: truncated PE header`);
+ assert.equal(bytes.readUInt32LE(offset), 0x4550, `${path}: missing PE signature`);
+ assert.equal(bytes.readUInt16LE(offset + 4), 0xaa64, `${path}: expected ARM64 machine type`);
+ console.log(`Verified ARM64: ${path}`);
+}
diff --git a/frontend/src-tauri/src/lib.rs b/frontend/src-tauri/src/lib.rs
index 3c5d6686..461a6415 100644
--- a/frontend/src-tauri/src/lib.rs
+++ b/frontend/src-tauri/src/lib.rs
@@ -8,8 +8,12 @@ use tokio::sync::Mutex;
const OLLAMA_PORT: u16 = 11434;
const JARVIS_PORT: u16 = 8000;
+#[cfg(not(all(target_os = "windows", target_arch = "aarch64")))]
const DESKTOP_UV_SYNC_COMMAND: &str =
"uv sync --extra desktop --extra inference-cloud --extra inference-google --group desktop-native";
+#[cfg(all(target_os = "windows", target_arch = "aarch64"))]
+const DESKTOP_UV_SYNC_COMMAND: &str =
+ "uv sync --python cpython-3.12-windows-x86_64-none --extra desktop --extra inference-cloud --extra inference-google --group desktop-native";
/// Small, fast model used when startup needs a default Ollama tag.
const STARTUP_MODEL: &str = "qwen3.5:4b";
@@ -189,6 +193,20 @@ fn home_dir() -> String {
fn resolve_bin(name: &str) -> String {
let home = home_dir();
+ // Tauri installs the Windows ARM64 sidecar beside the desktop executable.
+ // Prefer the bundled runtime over an unrelated Ollama install on PATH.
+ #[cfg(all(target_os = "windows", target_arch = "aarch64"))]
+ if name == "ollama" {
+ if let Ok(exe) = std::env::current_exe() {
+ if let Some(dir) = exe.parent() {
+ let sidecar = dir.join("ollama.exe");
+ if sidecar.is_file() {
+ return sidecar.to_string_lossy().into_owned();
+ }
+ }
+ }
+ }
+
#[cfg(not(target_os = "windows"))]
let candidates = vec![
format!("/opt/homebrew/bin/{name}"),
@@ -884,11 +902,38 @@ fn format_uv_sync_spawn_error(root: &std::path::Path, uv_bin: &str, err: &str) -
}
fn rust_toolchain_install_hint() -> &'static str {
+ #[cfg(all(target_os = "windows", target_arch = "aarch64"))]
+ return "The desktop app needs Rust and Visual Studio Build Tools with the x64 C++ workload \
+ for its x64 Python backend. Install Rust from https://rustup.rs, run \
+ `rustup target add --toolchain stable x86_64-pc-windows-msvc`, then relaunch.";
+ #[cfg(not(all(target_os = "windows", target_arch = "aarch64")))]
"The desktop app needs the Rust toolchain to build `openjarvis_rust`. \
Install Rust from https://rustup.rs. On Windows, also install Visual Studio \
Build Tools with the C++ workload, then relaunch."
}
+/// Windows ARM64 runs the current Python dependency stack under x64 emulation:
+/// the locked numpy/pyarrow and speech wheels do not support win_arm64.
+/// The Tauri shell and bundled Ollama remain native ARM64 processes.
+#[cfg_attr(
+ not(all(target_os = "windows", target_arch = "aarch64")),
+ allow(unused_variables)
+)]
+fn prepare_backend_python(cmd: &mut tokio::process::Command) {
+ #[cfg(all(target_os = "windows", target_arch = "aarch64"))]
+ {
+ cmd.env("UV_PYTHON", "cpython-3.12-windows-x86_64-none");
+ // The PyO3 module must match the interpreter, not the desktop shell.
+ cmd.env("CARGO_BUILD_TARGET", "x86_64-pc-windows-msvc");
+ // Use the same stable compiler where the x64 target was installed,
+ // rather than selecting a separate toolchain through the MSRV pin.
+ cmd.env("RUSTUP_TOOLCHAIN", "stable");
+ // PyO3 cannot infer the target interpreter's ABI across host arches.
+ cmd.env("PYO3_CROSS_PYTHON_VERSION", "3.12");
+ cmd.env("PYO3_CROSS_PYTHON_IMPLEMENTATION", "CPython");
+ }
+}
+
fn looks_like_rust_extension_build_error(stderr: &str) -> bool {
let lower = stderr.to_ascii_lowercase();
[
@@ -956,6 +1001,7 @@ async fn verify_openjarvis_rust_extension(
.stderr(std::process::Stdio::piped())
.current_dir(root);
prepare_subprocess_for_appimage(&mut cmd);
+ prepare_backend_python(&mut cmd);
add_cargo_bin_to_path(&mut cmd);
cmd.kill_on_drop(true);
@@ -1499,6 +1545,7 @@ async fn boot_backend(backend: SharedBackend, status: SharedStatus) {
.current_dir(root);
// Avoid LD_LIBRARY_PATH leak when running inside an AppImage (#455).
prepare_subprocess_for_appimage(&mut sync_cmd);
+ prepare_backend_python(&mut sync_cmd);
add_cargo_bin_to_path(&mut sync_cmd);
sync_cmd.kill_on_drop(true);
let sync_output = sync_cmd.output().await;
@@ -1562,6 +1609,7 @@ async fn boot_backend(backend: SharedBackend, status: SharedStatus) {
// do this BEFORE cmd.env() calls below so our explicit cloud-key env
// additions aren't accidentally stripped.
prepare_subprocess_for_appimage(&mut cmd);
+ prepare_backend_python(&mut cmd);
// Inject cloud API keys from secure desktop storage.
for (key, value) in cloud_keys_for_inference(&cfg) {
diff --git a/tests/deployment/test_windows_arm64_desktop.py b/tests/deployment/test_windows_arm64_desktop.py
new file mode 100644
index 00000000..1f531a9d
--- /dev/null
+++ b/tests/deployment/test_windows_arm64_desktop.py
@@ -0,0 +1,138 @@
+"""Exercise ARM64 sidecar staging and reject incorrectly labelled executables."""
+
+from __future__ import annotations
+
+import os
+import shutil
+import struct
+import subprocess
+import zipfile
+from pathlib import Path
+
+import pytest
+
+ROOT = Path(__file__).resolve().parents[2]
+SCRIPTS = ROOT / "frontend/src-tauri/scripts"
+ARM_TARGET = "aarch64-pc-windows-msvc"
+
+
+def pe_executable(machine: int) -> bytes:
+ header = bytearray(128)
+ header[:2] = b"MZ"
+ struct.pack_into("<I", header, 0x3C, 64)
+ header[64:68] = b"PE\0\0"
+ struct.pack_into("<H", header, 68, machine)
+ return bytes(header)
+
+
+def sidecar_download(tmp_path):
+ """Use a real ZIP with a stubbed network, preserving extraction behavior."""
+ scripts = tmp_path / "src-tauri/scripts"
+ scripts.mkdir(parents=True)
+ script = scripts / "download-ollama.sh"
+ shutil.copy2(SCRIPTS / script.name, script)
+ archive = tmp_path / "ollama.zip"
+ with zipfile.ZipFile(archive, "w") as bundle:
+ bundle.writestr("ollama.exe", pe_executable(0xAA64))
+ bundle.writestr("root.dll", b"root runtime")
+ bundle.writestr("LICENSE", b"license notice")
+ bundle.writestr("lib/ollama/llama-server.exe", pe_executable(0xAA64))
+ bundle.writestr("lib/ollama/ggml-cpu.dll", b"CPU runtime")
+ stubs = tmp_path / "stubs"
+ stubs.mkdir()
+ curl = stubs / "curl"
+ curl.write_text(
+ '#!/bin/bash\nfor arg in "$@"; do\n'
+ ' case "$arg" in https:*) printf "%s" "$arg" > "$TEST_URL";; esac\n'
+ 'done\nwhile [ "$1" != "-o" ]; do shift; done\n'
+ 'cp "$TEST_ARCHIVE" "$2"\n'
+ )
+ curl.chmod(0o755)
+ uname = stubs / "uname"
+ uname.write_text(
+ '#!/bin/bash\ncase "$1" in -m) echo x86_64;; -s) echo MINGW64_NT;; esac\n'
+ )
+ uname.chmod(0o755)
+ env = {
+ **os.environ,
+ "PATH": f"{stubs}{os.pathsep}{os.environ['PATH']}",
+ "TEST_ARCHIVE": str(archive),
+ "TEST_URL": str(tmp_path / "url"),
+ "PROCESSOR_ARCHITECTURE": "AMD64",
+ "PROCESSOR_ARCHITEW6432": "ARM64",
+ }
+ return script, archive, env
+
+
+def download(script, env, *args):
+ return subprocess.run(
+ ["bash", str(script), *args], env=env, capture_output=True, text=True
+ )
+
+
[email protected]("explicit_target", [True, False])
+def test_stages_arm64_runtime_even_from_emulated_git_bash(
+ sidecar_download, explicit_target
+):
+ script, _, env = sidecar_download
+ result = download(script, env, *([ARM_TARGET] if explicit_target else []))
+ assert result.returncode == 0, result.stderr
+ assert Path(env["TEST_URL"]).read_text().endswith("/ollama-windows-arm64.zip")
+ binaries = script.parent.parent / "binaries"
+ runtime = binaries / f"ollama-runtime-{ARM_TARGET}"
+ assert (binaries / f"ollama-{ARM_TARGET}.exe").read_bytes() == pe_executable(0xAA64)
+ assert (runtime / "root.dll").read_bytes() == b"root runtime"
+ assert (runtime / "LICENSE").read_bytes() == b"license notice"
+ assert (runtime / "lib/ollama/ggml-cpu.dll").read_bytes() == b"CPU runtime"
+ assert not (runtime / "ollama.exe").exists()
+
+
+def test_rejects_arm64_archive_without_inference_runtime(sidecar_download):
+ script, archive, env = sidecar_download
+ with zipfile.ZipFile(archive, "w") as bundle:
+ bundle.writestr("ollama.exe", pe_executable(0xAA64))
+ result = download(script, env, ARM_TARGET)
+ assert result.returncode != 0
+ assert "missing its lib/ollama" in result.stdout
+ assert not (script.parent.parent / "binaries" / f"ollama-{ARM_TARGET}.exe").exists()
+
+
+def test_old_binary_only_cache_is_restaged(sidecar_download):
+ script, _, env = sidecar_download
+ binaries = script.parent.parent / "binaries"
+ binaries.mkdir()
+ binary = binaries / f"ollama-{ARM_TARGET}.exe"
+ binary.write_bytes(b"old incomplete cache")
+ result = download(script, env, ARM_TARGET)
+ assert result.returncode == 0, result.stderr
+ assert binary.read_bytes() == pe_executable(0xAA64)
+ assert (
+ binaries / f"ollama-runtime-{ARM_TARGET}/lib/ollama/llama-server.exe"
+ ).is_file()
+
+
+def test_explicit_x64_target_wins_over_arm_host(sidecar_download):
+ script, _, env = sidecar_download
+ result = download(script, env, "x86_64-pc-windows-msvc")
+ assert result.returncode == 0, result.stderr
+ assert Path(env["TEST_URL"]).read_text().endswith("/ollama-windows-amd64.zip")
+
+
+ ("payload", "valid"),
+ [
+ (pe_executable(0xAA64), True),
+ (pe_executable(0x8664), False),
+ (b"not a PE", False),
+ ],
+)
+def test_arm64_check_reads_machine_type(tmp_path, payload, valid):
+ executable = tmp_path / "ollama.exe"
+ executable.write_bytes(payload)
+ result = subprocess.run(
+ ["node", str(SCRIPTS / "verify-arm64-pe.mjs"), str(executable)],
+ capture_output=True,
+ text=True,
+ )
+ assert (result.returncode == 0) is valid, result.stderr