Skip to content

[Bug] Windows: desktop auto-repair deadlocks on its own runtime lock; setup deps (uv) cannot replace pydantic-core loaded by the setup interpreter #9928

Closed

Description

@baoyu0

Summary

On Windows, the Unsloth Studio desktop app can get stuck in a permanent auto-repair loop after a failed llama.cpp update / failed CLI self-update. Two related bugs make the situation unrecoverable from inside the app:

  1. Auto-repair deadlocks on its own runtime lock (the repair runs while the desktop app — which holds the lock — is still running).
  2. The bundled setup's "studio deps" step fails deterministically on Windows: uv cannot replace pydantic-core because the setup interpreter itself has _pydantic_core.cp313-win_amd64.pyd loaded, and the rollback then restores the exact broken state every time, so retries can never succeed.

Environment

  • Windows 11 (HP OMEN laptop), NVIDIA RTX 5060 Ti (CUDA 13)
  • Unsloth Studio desktop app v0.1.804-beta
  • Managed env: unsloth 2026.8.22, Python 3.13.15, installer-pinned uv 0.12.1

Symptom 1 — llama.cpp update failure message is misleading (minor)

[llama-prebuilt] rename llama.cpp -> llama.cpp.rollback-20260828133859-17784 blocked (5), retrying in 1.00s -- a scanner is likely still holding the install open
...
[llama-prebuilt] activation failed for staged install: [WinError 5] 拒绝访问。
[llama-prebuilt] prebuilt busy reason: ... llama.cpp appears to still be in use; previous install left in place

On this machine the real root cause was corrupted ACLs on C:\Users\zhaid\.unsloth\llama.cpp, not a scanner: even icacls / Get-Acl returned access-denied for the directory. takeown /F ... /R /D Y + icacls ... /reset /T /C fixed it and the update then succeeded.

Suggestion: when the rename keeps failing with ERROR_ACCESS_DENIED (5) rather than ERROR_SHARING_VIOLATION (32), also print the takeown / icacls /reset hint instead of only the "scanner" theory (install.ps1 has such a hint elsewhere, but the llama-prebuilt installer never surfaces it).

Symptom 2 — auto-repair deadlocks on the runtime lock it can never acquire (main bug)

After a failed CLI self-update left Scripts\unsloth.exe missing (it was renamed to unsloth.exe.update-backup and the new file was never placed), startup preflight reports ManagedStale / cli_unusable and the app auto-starts repair. The repair then runs while the desktop app itself is alive:

[update] Starting backend update via "C:\Users\zhaid\.unsloth\studio\unsloth_studio\Scripts\unsloth.exe"
[ERROR] [update] Could not create the Unsloth runtime lock: 拒绝访问。 (os error 5)
[WARN] Managed repair update failed, falling back to bundled installer
[install] [ERROR] Unsloth Studio is starting or installation is already running.
[install] [stdout] [TAURI:ERROR_DEFAULT] The managed Unsloth environment is busy
[ERROR] Managed repair installer failed: Installation failed: The managed Unsloth environment is busy

The runtime lock (named mutex) is held by the running app, so the update process cannot create it (os error 5), and the bundled install.ps1 refuses because the app is running. The auto-repair can never succeed from inside the app. The only workaround is closing the app manually and running install.ps1 from a terminal.

Symptom 3 — setup "studio deps" step fails deterministically on Windows (root of the stuck install)

During unsloth studio setup, the ordered dependency install (step 6/12 "studio deps") runs:

uv pip install --python <venv>\Scripts\python.exe -r studio.txt

uv wants to (re)install pydantic-core; the setup process (the venv python) already has _pydantic_core.cp313-win_amd64.pyd loaded in memory, so deletion is denied by Windows:

Resolved 131 packages in 1.96s
error: failed to remove file `...\Lib\site-packages\pydantic_core\_pydantic_core.cp313-win_amd64.pyd`: 拒绝访问。 (os error 5)

The pip fallback then reports a secondary error:

Attempting uninstall: pydantic-core
  Found existing installation: pydantic-core None
error: uninstall-no-record-file
× Cannot uninstall pydantic-core None
╰─> The package's contents are unknown: no RECORD file was found for pydantic-core.
hint: You might be able to recover from this via: pip install --ignore-installed --no-deps pydantic-core==2.46.5

This failed identically across 6 installer runs, including one started from a completely fresh venv (I deleted unsloth_studio entirely before that run). On failure, install.ps1 prints "preserving existing environment for rollback" / "restoring previous environment after failed install" and restores the exact broken seed it saved at start — so every retry starts from the same corrupted state and retrying can never succeed. Users are stuck until they manually delete the venv and/or fix the package by hand.

Workaround that eventually worked (no code change):

  1. venv\Scripts\python.exe -m pip install -r studio.txt -c constraints.txt (pip handles the already-installed pydantic-core fine)
  2. restore Scripts\unsloth.exe from studio\bin\unsloth.exe
  3. regenerate the install manifest: python -c "import studio.install_manifest as m; m.write_manifest()"
  4. the app then boots Ready and the backend serves normally.

Suggested fixes

  1. Repair must not require a runtime lock held by the running app. Either run the repair/installer out-of-process so it owns the lock, or have the app prompt the user to fully quit before repairing.
  2. On Windows, the deps step should not delete a .pyd loaded by the setup interpreter. Options: pre-install the pinned pydantic-core before setup imports it; run the uv step from a separate clean interpreter; or, when uninstall fails with ERROR_ACCESS_DENIED on a loaded DLL, fall back to --ignore-installed / --force-reinstall (which writes fresh files without needing to delete the loaded one — the uv hint already suggests pip install --ignore-installed --no-deps pydantic-core==...).
  3. Rollback should preserve a known-good baseline, and/or unsloth studio update should self-heal the install manifest, so a partial install doesn't permanently wedge preflight into auto-repair (studio_install_incomplete).
  4. The CLI self-update must restore unsloth.exe on failure instead of leaving unsloth.exe.update-backup with no replacement.

Logs

Full tauri.log and installer output for all 6 runs are available on request.

Activity

  1. danielhanchen commented on Oct 11, 2026

    @danielhanchen
    Member

    Fixed! Sorry on the delay. The setup step that could not replace pydantic-core was the update command itself holding pydantic in memory, fixed in #9890. The repair loop was the app reading a runtime lock held by an Unsloth process running as administrator (for example install.ps1 from an admin terminal) as a broken install instead of busy, fixed in #13301. The misleading scanner hint on access-denied renames was fixed in #10075 and #10182, and the launcher is now restored after a failed self-update.
    To update: Unsloth Desktop will have an update banner (the runtime lock fix ships in the next Desktop release). For Studio, use unsloth studio update. For Docker, use docker exec <container> unsloth-studio-update. Reopen if it still happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions