Skip to content

Uninstall the whisper.cpp prebuilt and the node/whisper install locks - #7686

Merged
danielhanchen merged 4 commits into
mainfrom
uninstall-prebuilt-artifacts
Aug 1, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
uninstall-prebuilt-artifacts

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

scripts/uninstall.sh removed the llama.cpp prebuilt and its install lock, but not:

  • ~/.unsloth/whisper.cpp (the managed dictation engine)
  • ~/.unsloth/.node.install.lock
  • ~/.unsloth/.whisper.cpp.install.lock
  • ~/.unsloth/.<name>.install.lock.stale.<pid>

Every prebuilt serializes on <parent>/.<name>.install.lock (prebuilt_core.py install_lock_path), so llama.cpp, node and whisper.cpp each leave one. Only the llama.cpp lock was being cleared.

A stray zero-byte lock looks harmless, but the last step of the block is rmdir "$HOME/.unsloth", and rmdir refuses a non-empty directory. So a single missed lock keeps the entire ~/.unsloth tree on disk after a "successful" uninstall.

Evidence

A real install.sh -> unsloth studio update x3 -> scripts/uninstall.sh run on ubuntu-latest, diffing the whole $HOME tree against a pristine snapshot:

survivors under .unsloth:
./.unsloth
./.unsloth/.node.install.lock

whisper.cpp did not appear there only because that run skipped it: the installer logged whisper.cpp no compatible prebuilt (installed llama.cpp b10194-mix-f08678f; whisper requires b10173-mix-2c8b9c1). Installs that do get a matching prebuilt leave the whole whisper.cpp tree behind, which is why the new test creates it unconditionally rather than relying on a live install to produce it.

Changes

  • Remove ~/.unsloth/whisper.cpp, the node and whisper install locks, and any .stale.<pid> locks left by a lock takeover (install_node_prebuilt.py renames rather than deletes those).
  • --help now names the sibling prebuilts it removes (~/.unsloth/{llama.cpp,node,whisper.cpp,.cache}); previously it only mentioned the install dir.
  • studio-update-smoke.yml gains the specific paths plus a ~/.unsloth catch-all. Nothing but Unsloth writes there on a runner, so a surviving directory means the uninstaller missed something. That assertion does not need editing when a new artifact is added, which is exactly the failure mode here.

Tests

tests/sh/test_uninstall_prebuilt_artifacts.sh runs the uninstaller for real against a fixture HOME (picked up automatically by the tests/sh/test_*.sh discovery in studio-backend-ci.yml).

  • 19 checks pass on this branch.
  • 8 of those 19 fail against the previous scripts/uninstall.sh, so the test discriminates rather than passing vacuously.
  • It also asserts the reverse: a user file or directory under ~/.unsloth is kept, ~/.unsloth is then correctly retained for it, and the Unsloth artifacts around it are still cleared.

tests/sh/test_uninstall_arg_guard.sh still passes 25/25. dash, bash and busybox sh all parse the modified script.

Not changed

Two survivors are deliberate and left alone:

  • ~/Documents/Unsloth Studio/ is user project content, in the same class as the Hugging Face cache the uninstaller already documents as preserved.
  • The export PATH="$HOME/.local/bin:$PATH" line install.sh appends to the shell rc. That is the standard XDG user bin directory, shared with anything else installed there, so removing it could break unrelated tools.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2fa013247

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/uninstall.sh
# Managed whisper.cpp dictation engine (install_whisper_prebuilt.py), a sibling
# of studio in default mode. Only present when a whisper prebuilt matching the
# pinned llama.cpp build existed at install time, so many installs lack it.
_remove_path "$HOME/.unsloth/whisper.cpp"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve user-configured whisper.cpp directories

When UNSLOTH_WHISPER_CPP_PATH points to $HOME/.unsloth/whisper.cpp, or UNSLOTH_SKIP_WHISPER_INSTALL=1 is used with a user-owned checkout there, studio/setup.sh:2207-2210 explicitly skips the managed installation, but this unconditional removal still recursively deletes that directory during uninstall. Gate deletion on an Unsloth ownership marker or prebuilt manifest so uninstalling Studio cannot erase a supported user-managed whisper.cpp tree.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not taking this one. The whisper line is symmetric with the long-standing llama.cpp behaviour two lines above it, so it is a pre-existing design decision rather than something this PR introduces. grep for UNSLOTH_LLAMA_CPP_PATH in scripts/uninstall.sh returns exactly one hit, the comment on line 261 itself: the uninstaller never reads the variable. "A user-set UNSLOTH_LLAMA_CPP_PATH is intentionally kept" therefore means only that a custom path elsewhere is untouched because we delete the fixed default path. A user pointing the variable at the managed default has always had that directory removed. The ownership marker you point at (_assert_studio_owned_or_absent, setup.sh) is gated on the studio home being custom, so it deliberately does not apply in default mode, where ~/.unsloth/whisper.cpp is the managed location. Adding a marker for whisper alone while llama.cpp, node and .cache stay unconditional would make the uninstaller less consistent, and --help now states plainly that these siblings are removed.

Comment on lines +81 to +82
HOME="$FIXTURE_HOME" sh "$UNINSTALL_SH" > "$_TMP_ROOT/out.log" 2>&1 || {
echo " FAIL: uninstall exited $?"; FAIL=$((FAIL + 1)); cat "$_TMP_ROOT/out.log"; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Isolate WSL-wide cleanup before invoking the real uninstaller

When this test suite is run on WSL, overriding HOME does not isolate the platform-wide cleanup because the uninstaller detects WSL from /proc/version and then uses the real powershell.exe, /mnt/*/Users, and /etc/profile.d paths in scripts/uninstall.sh:324-463. This invocation can therefore remove the developer's live Windows shortcuts, shared icon, and /etc/profile.d/unsloth-rocm-wsl.sh; stub WSL detection and its external commands, or add a narrowly scoped test mode, before running the uninstaller against the fixture.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, fixed in d8bf12c. The sibling suite tests/sh/test_uninstall_arg_guard.sh already skips on WSL for exactly this reason ("the uninstall body reaches Windows-side state outside the fixture") and this one did not. Confirmed the reachable paths: the WSL branch shells out to powershell.exe to delete "Unsloth Studio*.lnk" and the shared unsloth.ico, the interop-off fallback scans /mnt/{c,d,e}/Users, and it sudo-removes /etc/profile.d/unsloth-rocm-wsl.sh. None of those sit under HOME. The suite now exits 0 early when /proc/version reports microsoft.

@danielhanchen

Copy link
Copy Markdown
Member Author

Verified on real runners before and after, using a staging copy of this repo so the org queue is not charged for it. The job runs install.sh -> unsloth studio update x3 -> scripts/uninstall.sh, then diffs the whole $HOME tree against a pristine snapshot taken before the install.

Before the fix, both platforms left the same thing behind:

runner survivors under ~/.unsloth
ubuntu-latest ./.unsloth, ./.unsloth/.node.install.lock
macos-14 ./.unsloth, ./.unsloth/.node.install.lock

After the fix, with the audit turned from a probe into a hard assertion:

ubuntu-latest   PASS: no Unsloth artifacts survived the uninstall
macos-14        PASS: no Unsloth artifacts survived the uninstall

The same job also confirms the update is idempotent (+58 -0 paths between the 2nd and 3rd update, all of it cache and log churn) and that a second and third uninstall.sh both exit 0.

scripts/uninstall.sh removed the llama.cpp prebuilt and its install lock but
not the whisper.cpp prebuilt, and not the node or whisper install locks. Every
prebuilt serializes on <parent>/.<name>.install.lock (prebuilt_core.py
install_lock_path), so a normal install leaves ~/.unsloth/.node.install.lock
behind. The final rmdir refuses a non-empty directory, so one stray zero-byte
lock keeps the whole ~/.unsloth tree on disk.

Confirmed on a real ubuntu-latest install -> update x3 -> uninstall run:
~/.unsloth and ~/.unsloth/.node.install.lock both survived. whisper.cpp is
only installed when a prebuilt matching the pinned llama.cpp build exists, so
runs that skip it never exercised that path.

Also removes the .stale.<pid> locks that a lock takeover renames rather than
deletes, documents the sibling prebuilts in --help, and adds a ~/.unsloth
catch-all to the smoke workflow's leak list so a future artifact cannot be
missed the same way.

tests/sh/test_uninstall_prebuilt_artifacts.sh runs the uninstaller for real
against a fixture HOME: 19 checks pass here and 8 of them fail against the
previous uninstall.sh. It also asserts user content under ~/.unsloth is kept.
@danielhanchen
danielhanchen force-pushed the uninstall-prebuilt-artifacts branch from c2fa013 to 081d4e0 Compare July 31, 2026 12:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 081d4e0159

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/uninstall.sh
# Managed whisper.cpp dictation engine (install_whisper_prebuilt.py), a sibling
# of studio in default mode. Only present when a whisper prebuilt matching the
# pinned llama.cpp build existed at install time, so many installs lack it.
_remove_path "$HOME/.unsloth/whisper.cpp"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Mirror the prebuilt cleanup in uninstall.ps1

This cleanup only updates the POSIX uninstaller, so native Windows installations still leave the managed whisper.cpp tree and the Node/whisper lock files behind. studio/setup.ps1:4085-4099 installs whisper.cpp under %USERPROFILE%\.unsloth\whisper.cpp, while scripts/uninstall.ps1:361-425 removes only llama.cpp, Node, staging, and the llama lock; its Windows smoke assertion at .github/workflows/studio-windows-update-smoke.yml:313-317 also checks only the Studio tree. Mirror these removals in scripts/uninstall.ps1 and extend that smoke check so Windows users receive the same complete uninstall behavior.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, fixed in d8bf12c. Confirmed against origin/main: uninstall.ps1 removed llama.cpp, .cache, node and .staging, plus only .llama.cpp.install.lock, while setup.ps1 installs whisper.cpp at %USERPROFILE%.unsloth\whisper.cpp. The locks are generic (install_dir.parent/'..install.lock' in prebuilt_core.py), so .node.install.lock and .whisper.cpp.install.lock were both leaking and either one blocks the empty-dir prune. Added the whisper dir, all three locks and the .stale. sweep, put the whisper dir in the handle-releasing list so a running whisper-server does not refuse the delete, updated -Help, and extended the Windows smoke assertion with the same catch-all the POSIX one got. Also added tests/studio/test_uninstall_prebuilt_parity.ps1, which asserts the two uninstallers cover the same artifacts; against the previous uninstall.ps1 it fails on exactly the four missing behaviours.

@danielhanchen

Copy link
Copy Markdown
Member Author

The new suite also runs clean on both POSIX runners, with a negative control proving it discriminates:

runner test_uninstall_prebuilt_artifacts.sh test_uninstall_arg_guard.sh against the pre-fix uninstaller
ubuntu-latest 19 passed, 0 failed 25 passed, 0 failed 8 failures
macos-14 19 passed, 0 failed 24 passed, 0 failed 8 failures

macOS runs one fewer argument-guard case because the truncated-download check needs Linux F_SETPIPE_SZ, which that suite already skips explicitly.

The eight failures on the pre-fix script are the same set on both platforms: whisper.cpp, the node and whisper install locks, both .stale.<pid> locks, ~/.unsloth not being pruned, and the two "artifacts still cleared" assertions from the user-content case.

…n WSL

Two review findings.

uninstall.ps1 removed llama.cpp, node, .staging and the llama lock, but not the
whisper.cpp tree or the node and whisper locks, while setup.ps1 installs
whisper.cpp at %USERPROFILE%\.unsloth\whisper.cpp. A native Windows uninstall
therefore left a prebuilt tree behind and could never prune ~/.unsloth. Adds the
whisper dir, all three locks and the .stale.<pid> sweep, puts the whisper dir in
the handle-releasing list so a running whisper-server does not block the delete,
updates -Help, and extends the Windows smoke assertion with the same catch-all
the POSIX one got.

tests/sh/test_uninstall_prebuilt_artifacts.sh runs the real uninstaller, and
overriding HOME does not contain that on WSL: the body detects WSL from
/proc/version and then deletes Windows-side shortcuts under /mnt/*/Users and
/etc/profile.d/unsloth-rocm-wsl.sh. The sibling arg-guard suite already skips
there for exactly this reason; this one now does too.

tests/studio/test_uninstall_prebuilt_parity.ps1 asserts the two uninstallers
cover the same artifacts, since drift between them is what caused this. It
cannot run the body (that kills processes and writes the registry) so it parses
uninstall.ps1 instead. Against the previous uninstall.ps1 it fails on exactly
the four missing behaviours.

Also corrects the stale-lock comment: install_node_prebuilt.py renames then
unlinks, so a stranded .stale file needs a crash between the two steps.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: d8bf12c653

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 425c908 into main Aug 1, 2026
23 of 24 checks passed
@danielhanchen
danielhanchen deleted the uninstall-prebuilt-artifacts branch August 1, 2026 10:03

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0185fdd5be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/uninstall.sh
Comment on lines +295 to +296
for _stale in "$HOME"/.unsloth/.*.install.lock.stale.*; do
[ -e "$_stale" ] && _remove_path "$_stale"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict stale-lock deletion to managed component names

When a user keeps any file or directory under ~/.unsloth whose name happens to match .*.install.lock.stale.*, this catch-all deletes it recursively even though the uninstaller promises to retain unrelated content. The installers only create stale locks for the known llama.cpp, node, and whisper.cpp components, so enumerate those prefixes instead; the mirrored *.install.lock.stale.* sweep in uninstall.ps1 has the same issue.

Useful? React with 👍 / 👎.

Comment on lines +13 to +17
# The uninstaller body kills processes and writes to the registry, so it cannot
# be executed here; this asserts PARITY of the artifact list instead, plus that
# uninstall.ps1 still parses.
#
# Run: pwsh -NoProfile -File tests/studio/test_uninstall_prebuilt_parity.ps1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Run the new PowerShell parity test in CI

This test is never invoked by any workflow: the Windows update workflow's unit-test step only runs test_uninstall_arg_guard.ps1 and test_uninstall_dual_install_icon.ps1, while the repository's automatic shell discovery only covers tests/sh/test_*.sh. Consequently a future Windows parity regression can pass CI whenever the live install skips the optional whisper prebuilt—the exact scenario this static test was added to cover.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant