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
Record the venv own requirement digests, not the installers (#9263)
Daniel Han2e3cc032f631
diff --git a/.github/workflows/desktop-app-clean-machine-ci.yml b/.github/workflows/desktop-app-clean-machine-ci.ymlindex 7bcff2a4ef6..e3f6bd64b74 100644--- a/.github/workflows/desktop-app-clean-machine-ci.yml+++ b/.github/workflows/desktop-app-clean-machine-ci.yml@@ -276,7 +276,14 @@ jobs:cp "$f" logs/ 2>/dev/null || truetail -60 "$f"# The two fields the bug report turned on.- grep -E "disposition=|can_auto_repair=|Xcode Command Line|ModuleNotFoundError" "$f" || true+ # "Managed preflight" is not decoration. The disposition is the symptom;+ # the reason is the diagnosis, and it is logged on a separate line that+ # `tail -60` above scrolls away the moment the backend starts chattering.+ # On 2026-08-19 this went red on all four platforms and printed nothing+ # but "saw: ManagedStale"; the reason that actually explained it,+ # studio_install_requirements_changed, had to be recovered by hand from+ # the uploaded artifact.+ grep -E "disposition=|can_auto_repair=|Managed preflight|Xcode Command Line|ModuleNotFoundError" "$f" || truefound=1if grep -qE "desktop_preflight completed disposition=" "$f"; then disposition=1; fidispositions="${dispositions:-} $(grep -oE 'desktop_preflight completed disposition=[A-Za-z]+' "$f" | sed 's/.*disposition=//' | tr '\n' ' ')"@@ -520,7 +527,14 @@ jobs:for f in "$UNSLOTH_STUDIO_HOME/tauri.log" "$HOME/.unsloth/studio/tauri.log"; do[ -f "$f" ] || continueecho "=== $f ==="; cp "$f" logs/ 2>/dev/null || true; tail -60 "$f"- grep -E "disposition=|can_auto_repair=|ModuleNotFoundError" "$f" || true+ # "Managed preflight" is not decoration. The disposition is the symptom;+ # the reason is the diagnosis, and it is logged on a separate line that+ # `tail -60` above scrolls away the moment the backend starts chattering.+ # On 2026-08-19 this went red on all four platforms and printed nothing+ # but "saw: ManagedStale"; the reason that actually explained it,+ # studio_install_requirements_changed, had to be recovered by hand from+ # the uploaded artifact.+ grep -E "disposition=|can_auto_repair=|Managed preflight|ModuleNotFoundError" "$f" || truefound=1if grep -qE "desktop_preflight completed disposition=" "$f"; then disposition=1; fidispositions="${dispositions:-} $(grep -oE 'desktop_preflight completed disposition=[A-Za-z]+' "$f" | sed 's/.*disposition=//' | tr '\n' ' ')"@@ -801,7 +815,9 @@ jobs:Write-Host "=== $f ==="Copy-Item $f logs/ -ErrorAction SilentlyContinueGet-Content $f -Tail 60- Select-String -Path $f -Pattern 'disposition=|can_auto_repair=|ModuleNotFoundError' `+ # See the Linux job: the reason line is what explains a disposition,+ # and Get-Content -Tail 60 above scrolls it away.+ Select-String -Path $f -Pattern 'disposition=|can_auto_repair=|Managed preflight|ModuleNotFoundError' `-ErrorAction SilentlyContinue$found = $true$hits = @(Select-String -Path $f -Pattern 'desktop_preflight completed disposition=(\w+)')diff --git a/studio/install_manifest.py b/studio/install_manifest.pyindex 82bcf0d1f57..fec8a59591f 100644--- a/studio/install_manifest.py+++ b/studio/install_manifest.py@@ -77,6 +77,32 @@ def _sha256(path: Path) -> Optional[str]:return None+def installed_requirements_root(root: Optional[Path] = None) -> Optional[Path]:+ """The requirements the venv's *installed* package ships, if it has them.++ The digests must describe the files `verify_install` will later read, and+ that is always the installed package's copy: at verify time this module is+ imported out of the venv, so `requirements_root()` resolves there, and+ unsloth_cli/_studio_deps.py looks in the same place for a foreign venv.++ The installer is a different tree. A desktop bundle carries its own+ `studio/install_python_stack.py`, and its requirements are whatever they were+ when that bundle was cut -- so recording the installer's digests makes every+ install stale the moment a tracked requirement file changes upstream. That is+ not hypothetical: v0.1.800-beta (2026-08-14) installed unsloth 2026.8.18,+ #9148 had pinned openai in extras.txt in between, and every fresh Linux and+ macOS desktop install came up `studio_install_requirements_changed` and paid+ an immediate repair pass before it would run.+ """+ prefix = root or venv_root()+ for pattern in ("lib/python*/site-packages", "Lib/site-packages"):+ for site in sorted(prefix.glob(pattern)):+ reqs = site / "studio" / "backend" / "requirements"+ if reqs.is_dir():+ return reqs+ return None++def requirement_digests(req_root: Optional[Path] = None) -> Dict[str, str]:"""sha256 of every tracked requirement file that exists."""root = req_root or requirements_root()@@ -139,7 +165,12 @@ def write_manifest("platform": f"{sys.platform}-{platform.machine()}","prefix": str(venv_root()),"steps_total": steps_total,- "requirement_files": requirement_digests(req_root),+ # The venv's own copy wins over the caller's. `verify_install` reads the+ # installed package's requirements, so recording the installer's would+ # compare two different trees and call a finished install stale. An+ # editable / source install has no copy under site-packages, and there+ # the caller's root is already the tree both sides read.+ "requirement_files": requirement_digests(installed_requirements_root(root) or req_root),}# Additive, so MANIFEST_SCHEMA does not move and every existing manifest stays# valid. Absent means "unknown", which is NOT False: only a manifest written bydiff --git a/tests/studio/install/test_install_manifest.py b/tests/studio/install/test_install_manifest.pyindex 4313315b2d5..97741e9627a 100644--- a/tests/studio/install/test_install_manifest.py+++ b/tests/studio/install/test_install_manifest.py@@ -278,3 +278,69 @@ def test_set_no_torch_marker_clears_itself_and_never_raises(install_root):# Absent directory: must degrade quietly, it runs mid-install.im.set_no_torch_marker(True, root = install_root / "does" / "not" / "exist")+++def _fake_venv(root, files):+ """A venv-shaped tree whose installed package ships its own requirements."""+ site = root / "lib" / "python3.12" / "site-packages"+ reqs = site / "studio" / "backend" / "requirements"+ (reqs / "single-env").mkdir(parents = True, exist_ok = True)+ for name, body in files.items():+ (reqs / name).write_text(body, encoding = "utf-8")+ return reqs+++def test_the_manifest_records_the_venvs_own_requirements_not_the_installers(install_root, req_root):+ """+ The regression that broke every fresh desktop install on 2026-08-19.++ A desktop bundle carries its own `studio/install_python_stack.py`, so the+ digests used to come from whatever that bundle shipped. Verification reads+ the *installed* package's copy. v0.1.800-beta (2026-08-14) installed unsloth+ 2026.8.18, #9148 had pinned openai in extras.txt in between, and the two+ trees disagreed: every install came up `studio_install_requirements_changed`+ and repaired itself before it would run.++ So the two roots are made deliberately different here, and the manifest must+ describe the one the verifier will read.+ """+ installed = _fake_venv(+ install_root, {"studio.txt": "pytest\n", "extras.txt": "openai==3.2.0\n"}+ )+ # The installer's tree, as an older bundle would carry it.+ (req_root / "studio.txt").write_text("pytest\n", encoding = "utf-8")+ (req_root / "extras.txt").write_text("openai>=2.7.2\n", encoding = "utf-8")++ im.write_manifest(root = install_root, req_root = req_root, package_name = "pytest")++ recorded = json.loads((install_root / im.MANIFEST_NAME).read_text(encoding = "utf-8"))+ assert recorded["requirement_files"] == im.requirement_digests(installed), (+ "the manifest recorded the installer's requirement digests; verification "+ "reads the installed package's, so a bundle even one commit behind marks "+ "every install it performs as stale"+ )++ # And the whole point: the install it just described reads as finished.+ state = im.verify_install(root = install_root, req_root = installed, package_name = "pytest")+ assert state["manifest_ok"] is True, state["reason"]+++def test_a_source_install_still_uses_the_root_it_was_given(install_root, req_root):+ """+ An editable / `--local` install has no copy under site-packages, and there the+ caller's root is already the tree both sides read. Falling back to it is what+ keeps test_edited_requirements_invalidate_the_manifest meaningful.+ """+ assert im.installed_requirements_root(install_root) is None+ im.write_manifest(root = install_root, req_root = req_root, package_name = "pytest")+ recorded = json.loads((install_root / im.MANIFEST_NAME).read_text(encoding = "utf-8"))+ assert recorded["requirement_files"] == im.requirement_digests(req_root)+++def test_the_venv_resolver_finds_both_layouts(tmp_path):+ """posix `lib/python3.x/site-packages` and Windows `Lib/site-packages`."""+ for layout in ("lib/python3.12/site-packages", "Lib/site-packages"):+ root = tmp_path / layout.replace("/", "_")+ reqs = root / layout / "studio" / "backend" / "requirements"+ reqs.mkdir(parents = True)+ assert im.installed_requirements_root(root) == reqs