install: six round-five review fixes across provisioner, setup, uninstall

Fifth review round; each item traced through the live scripts before fixing.

A provisioner fresh clone that failed to produce a server was left behind as
a markerless git tree; under a custom UNSLOTH_STUDIO_HOME the next run's
ownership assert refuses the unmarked dir and aborts the whole install until
the user deletes it by hand. _restore_prev now removes a clone this script
created when no server came out of it (backed-up dirs restore as before).

The CUDA provision gate ignored --with-llama-cpp-dir linked mode, so a
linked user tree with a CPU-only server could be checked out to a pinned
ref, rebuilt in place, or moved aside entirely and replaced by a fresh
clone. The gate now skips linked local dirs.

uninstall.sh removed the CUDA build artifacts without stopping a running
detached build; _pkill_studio only matches Studio roots, so live cmake/nvcc
kept burning thermals, recreated build files, and defeated the trailing
rmdir. The runner, provisioner, and llama.cpp-path processes now get
TERM-then-KILL with the same escape helper and grace the Studio kill uses.

The worker's memory-fraction guard classified Spark purely from device
props, so UNSLOTH_FORCE_DGX_SPARK=1 on an unlisted name got no fraction
guard (and the fraction env was dead), while FORCE=0 could not disable it;
the guard now honors the same force semantics as the detectors.

UNSLOTH_LLAMA_TAG / UNSLOTH_LLAMA_PR were interpolated into the runner
script's single-quoted exports unvalidated while every sibling forward has
an allow-list; they now get the INSTALL_REF ref allow-list and a digits-only
check respectively (own-machine robustness, not a trust boundary).

On WSL-fallback success with a custom UNSLOTH_STUDIO_HOME, the installer
deleted the rolled-aside custom-root venv right after telling the user that
root is not used by the WSL install; a custom root now restores the previous
venv instead (the WSL shim does not depend on the Windows venv), while the
default root keeps dropping the vestigial backup.

Verified: bash -n on all three shell scripts, AST parse on worker.py,
PowerShell AST parse on install.ps1, icon suites pass, sh battery matches
the branch baseline. Two resurfaced anchors (build/bin backup, --package
forwarding) confirmed already fixed at head.
This commit is contained in:
Daniel Han 2026-07-18 12:08:39 +00:00
commit af459f4673
5 changed files with 42 additions and 5 deletions

View file

@ -216,6 +216,20 @@ _remove_path "$HOME/.unsloth/studio"
# by deleting it). No-op in env/custom mode (they nest under the custom root) and
# when absent. A user-set UNSLOTH_LLAMA_CPP_PATH is intentionally kept.
_remove_path "$HOME/.unsloth/llama.cpp"
# Stop a detached CUDA llama.cpp build before deleting its tree: _pkill_studio
# only matches Studio roots, and a live cmake/nvcc under ~/.unsloth/llama.cpp
# would keep burning CPU/thermals, recreate build/ files, and defeat the
# trailing rmdir. TERM first, then KILL after the same grace _pkill_studio uses.
if command -v pkill >/dev/null 2>&1; then
_llama_re=$(_pkill_escape "$HOME/.unsloth/llama.cpp")
for _pat in "run_llama_build\.sh" "provision_llama_cuda\.sh" "$_llama_re"; do
pkill -TERM -f "$_pat" 2>/dev/null || true
done
sleep 0.5
for _pat in "run_llama_build\.sh" "provision_llama_cuda\.sh" "$_llama_re"; do
pkill -KILL -f "$_pat" 2>/dev/null || true
done
fi
# WoA/Spark CUDA-build path artifacts (provision script fetched by setup.sh,
# install.ps1's background-build runner + log, and the persisted shortcut-skip
# marker). No-ops when absent.