uninstall: fix WSL rm self-kill (rm before pkill) + clean native-Linux llama.cpp

- uninstall.ps1: the WSL-distro cleanup ran 'pkill -f "unsloth studio"' before the
  rm inside a single bash -lc, but that pattern matches the bash -lc's own argv ->
  pkill SIGKILLs the shell before rm runs, so /root/.unsloth survived. Reorder: rm
  FIRST (guaranteed), then non-self-matching fuser -k 8888/tcp + pkill best-effort;
  also remove the fetched provision script + build log.
- uninstall.sh: also remove ~/.unsloth/llama.cpp (CUDA build from provision on
  native-Linux Spark) + the fetched provision_llama_cuda.sh.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Daniel Han 2026-06-02 23:37:06 -07:00
commit c87550cb3b
2 changed files with 11 additions and 1 deletions

View file

@ -368,7 +368,11 @@ function Uninstall-UnslothStudio {
try {
$distros = @(((& wsl.exe --list --quiet 2>$null) -join "`n").Replace([char]0, '') -split "`r?`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ })
foreach ($d in $distros) {
& wsl.exe -d $d -u root -- bash -lc 'pkill -9 -f "unsloth studio" 2>/dev/null; pkill -9 -f "llama-server" 2>/dev/null; rm -rf /root/.unsloth /home/*/.unsloth /root/llama-cuda 2>/dev/null; true' 2>$null
# IMPORTANT: rm runs FIRST. `pkill -f "<pattern>"` matches this very
# bash -lc (its argv contains the pattern) and would SIGKILL the shell
# before a trailing rm could run. So remove files first (guaranteed),
# then best-effort kill: fuser by port (does not self-match) + pkill.
& wsl.exe -d $d -u root -- bash -lc 'rm -rf /root/.unsloth /home/*/.unsloth /root/llama-cuda /root/provision_llama_cuda.sh /root/llama_cuda_build.log 2>/dev/null; fuser -k 8888/tcp 2>/dev/null; pkill -9 -f unsloth_studio 2>/dev/null; pkill -9 -f llama-server 2>/dev/null; true' 2>$null
if ($LASTEXITCODE -eq 0) { _Substep "cleaned Unsloth from WSL distro: $d" "Green" }
}
} catch { }

View file

@ -209,6 +209,12 @@ _custom_studio_roots | while IFS= read -r _custom_root; do
_remove_path "$_custom_root"
done
_remove_path "$HOME/.unsloth/studio"
# CUDA llama.cpp built by provision_llama_cuda.sh on native-Linux Spark/aarch64
# (and the fetched provision script). On WSL ~/.unsloth/llama.cpp is a symlink to
# the real build, which install.ps1's uninstall removes; here rm -rf clears the
# native-Linux build dir / the symlink.
_remove_path "$HOME/.unsloth/llama.cpp"
_remove_path "$HOME/.unsloth/provision_llama_cuda.sh"
_remove_path "$HOME/.local/share/unsloth"
# CLI shim: only the symlink Studio created, never a pip-installed file.
_remove_cli_shim