diff --git a/scripts/uninstall.ps1 b/scripts/uninstall.ps1 index 782cc39290..5dc4052db9 100644 --- a/scripts/uninstall.ps1 +++ b/scripts/uninstall.ps1 @@ -377,7 +377,16 @@ function Uninstall-UnslothStudio { # ~/.local/bin/unsloth -> /bin/unsloth. rm -rf of ~/.unsloth # above deletes its target but leaves the symlink dangling, so the # `unsloth` command still resolves on PATH after an uninstall. - $_clean = 'rm -rf /root/.unsloth /home/*/.unsloth /root/llama-cuda /root/provision_llama_cuda.sh /root/llama_cuda_build.log 2>/dev/null; rm -f /root/.local/bin/unsloth /home/*/.local/bin/unsloth 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' + # The pkill patterns use the [x]-regex self-exclusion trick: this very + # `bash -lc ` shell's own argv contains the literal pattern text, so a + # plain `pkill -f unsloth_studio` would match (and SIGKILL) the shell itself + # before the next command runs -- which is why rm goes first AND why the second + # pkill (llama-server, a dynamic port not covered by `fuser -k 8888`) never + # fired. Writing the pattern as '[u]nsloth_studio' means the shell's argv holds + # "[u]nsloth_studio" (no literal "unsloth_studio" substring) so it no longer + # self-matches, while real target processes (cmdline contains "unsloth_studio") + # still match. Same for '[l]lama-server'. + $_clean = 'rm -rf /root/.unsloth /home/*/.unsloth /root/llama-cuda /root/provision_llama_cuda.sh /root/llama_cuda_build.log 2>/dev/null; rm -f /root/.local/bin/unsloth /home/*/.local/bin/unsloth 2>/dev/null; fuser -k 8888/tcp 2>/dev/null; pkill -9 -f ''[u]nsloth_studio'' 2>/dev/null; pkill -9 -f ''[l]lama-server'' 2>/dev/null; true' $_cands = @('', 'Ubuntu', 'Ubuntu-24.04', 'Ubuntu-22.04', 'Debian') if ($env:UNSLOTH_WSL_DISTRO) { $_cands = @($env:UNSLOTH_WSL_DISTRO) + $_cands } $_done = @{}