Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Tighten the comments around the uninstaller argument guard (#7647)
Daniel Han5344ec3e4924
diff --git a/.github/workflows/studio-windows-update-smoke.yml b/.github/workflows/studio-windows-update-smoke.ymlindex 7fb62ed72ff..6751c452813 100644--- a/.github/workflows/studio-windows-update-smoke.yml+++ b/.github/workflows/studio-windows-update-smoke.yml@@ -63,8 +63,7 @@ jobs:with:persist-credentials: false- # This workflow triggers on uninstall.ps1, so run both uninstaller unit- # tests here. The guard test cannot perform a real uninstall.+ # This workflow triggers on uninstall.ps1; neither test really uninstalls.- name: uninstall.ps1 unit tests (argument guard, dual-install icon preserve)shell: pwshrun: |@@ -74,10 +73,9 @@ jobs:pwsh -NoProfile -File tests/studio/test_uninstall_dual_install_icon.ps1if ($LASTEXITCODE) { exit $LASTEXITCODE }- # The argument guard is self-hosting via (Get-Process -Id $PID).Path, so- # launching it from powershell.exe exercises Windows PowerShell 5.1, the- # shell the README one-liner lands in on a stock Windows box. Nothing else- # in CI runs 5.1, and its native-stderr handling differs from pwsh 7.+ # The guard is self-hosting, so launching it from powershell.exe covers+ # Windows PowerShell 5.1: the shell the README one-liner lands in, handled+ # nowhere else in CI, and it differs from pwsh 7 on native stderr.- name: uninstall.ps1 argument guard under Windows PowerShell 5.1shell: powershellrun: |diff --git a/scripts/uninstall.ps1 b/scripts/uninstall.ps1index b524b129689..4a59dac8a07 100644--- a/scripts/uninstall.ps1+++ b/scripts/uninstall.ps1@@ -1,10 +1,8 @@# SPDX-License-Identifier: AGPL-3.0-only# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0#-# Unsloth Studio uninstaller for Windows PowerShell. Run -Help for removal-# details and options.-# Custom roots set via UNSLOTH_STUDIO_HOME / STUDIO_HOME at install time are-# read back from share\studio.conf.+# Unsloth Studio uninstaller for Windows PowerShell. Run -Help for details.+# Custom roots (UNSLOTH_STUDIO_HOME / STUDIO_HOME) come from share\studio.conf.## Usage: irm https://raw.githubusercontent.com/unslothai/unsloth/main/scripts/uninstall.ps1 | iex# Local: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass; .\scripts\uninstall.ps1diff --git a/scripts/uninstall.sh b/scripts/uninstall.shindex 92ecfa48104..29b12dea19a 100755--- a/scripts/uninstall.sh+++ b/scripts/uninstall.sh@@ -2,10 +2,8 @@# SPDX-License-Identifier: AGPL-3.0-only# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0#-# Unsloth Studio uninstaller (macOS / Linux / WSL). Run --help for removal-# details and options.-# Custom roots set via UNSLOTH_STUDIO_HOME / STUDIO_HOME at install time are-# read back from studio.conf.+# Unsloth Studio uninstaller (macOS / Linux / WSL). Run --help for details.+# Custom roots (UNSLOTH_STUDIO_HOME / STUDIO_HOME) come from studio.conf.## Usage: curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/main/scripts/uninstall.sh | shdiff --git a/tests/sh/test_uninstall_arg_guard.sh b/tests/sh/test_uninstall_arg_guard.shindex 5db73bef8b0..068ef88a904 100755--- a/tests/sh/test_uninstall_arg_guard.sh+++ b/tests/sh/test_uninstall_arg_guard.sh@@ -2,10 +2,8 @@# SPDX-License-Identifier: AGPL-3.0-only# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0#-# Argument and pipe-safety tests for scripts/uninstall.sh.-#-# Behavioral cases use an instrumented copy that aborts before uninstalling.-# The real no-argument case is skipped on WSL because it reaches host state.+# Argument and pipe-safety tests for scripts/uninstall.sh. Behavioral cases use+# an instrumented copy that aborts before uninstalling.set -eSCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"@@ -54,7 +52,6 @@ assert_not_says() {esac}-# Check the fixture as a unit.FIXTURE_PATHS=".unsloth/studio .unsloth/studio/auth/.desktop_secret .local/bin/unsloth .local/share/unsloth"# assert_fixture <label> <home> present|gone@@ -70,13 +67,11 @@ assert_fixture() {if [ -z "$_missing" ]; then ok "$1"; else nope "$1 (wrong state:$_missing)"; fi}-# Publish a validated fixture path. A global keeps setup failures from being-# hidden by command-substitution errexit behavior.+# A global, not command substitution: $() would swallow setup failures under -e.FIXTURE_HOME=""make_home() {- # Explicit template, not TMPDIR: BSD mktemp with no template implies -t and- # resolves the directory itself, so on macOS TMPDIR= lands a sibling of- # _TMP_ROOT and the check below aborts the suite.+ # Explicit template: BSD mktemp with no template implies -t and picks its+ # own directory, so TMPDIR= lands outside _TMP_ROOT on macOS.FIXTURE_HOME=$(mktemp -d "$_TMP_ROOT/home.XXXXXX") || FIXTURE_HOME=""case "$FIXTURE_HOME" in"$_TMP_ROOT"/*) ;;@@ -170,8 +165,7 @@ fiecho "=== behaviour: a piped --help must not break the writer ==="-# Shrink the pipe so an unread script tail produces a broken writer. Skip where-# Linux F_SETPIPE_SZ is unavailable.+# Shrink the pipe so an unread script tail produces a broken writer.if python3 -c 'import fcntl, sys; sys.exit(0 if sys.platform.startswith("linux") else 1)' 2>/dev/null; thenmake_homeverdict=$(UNINSTALL_SH="$UNINSTALL_SH" FAKE_HOME="$FIXTURE_HOME" python3 - <<'PY'@@ -209,7 +203,6 @@ PYcase "$verdict" inskip:*|vacuous:*) echo " SKIP: ${verdict#*: }" ;;*)- # Check both the writer and script exit codes.check "piped --help stays guarded" "ok:0:guarded" "$verdict";;esacdiff --git a/tests/studio/test_uninstall_arg_guard.ps1 b/tests/studio/test_uninstall_arg_guard.ps1index 80c2e7d2632..a4e4865ebbf 100644--- a/tests/studio/test_uninstall_arg_guard.ps1+++ b/tests/studio/test_uninstall_arg_guard.ps1@@ -1,10 +1,9 @@#!/usr/bin/env pwsh# SPDX-License-Identifier: AGPL-3.0-only# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-# Argument contract for scripts/uninstall.ps1.-#-# Tests run against a temporary copy that aborts before the first uninstall-# action, so a broken guard cannot perform a real uninstall.+# Argument contract for scripts/uninstall.ps1. Tests run against a temporary+# copy that aborts before the first uninstall action, so a broken guard cannot+# perform a real uninstall.## Run: pwsh -NoProfile -File tests/studio/test_uninstall_arg_guard.ps1@@ -41,18 +40,15 @@ function Check($name, $cond) {else { Write-Host " FAIL $name" -ForegroundColor Red; $script:failures++ }}-# Capture a native command's merged output without letting its stderr abort us.-# Windows PowerShell 5.1 raises a terminating NativeCommandError when a native-# command writes to stderr under $ErrorActionPreference = "Stop"; PowerShell-# 7.1+ does not. This suite is self-hosting via (Get-Process -Id $PID).Path, so-# it can run under 5.1, where every rejected-argument case writes to stderr.+# Windows PowerShell 5.1 turns a native command's stderr into a terminating+# NativeCommandError under $ErrorActionPreference = "Stop"; 7.1+ does not. This+# suite can run under 5.1, where every rejected-argument case writes to stderr.function Invoke-Native([scriptblock]$Command) {$prev = $ErrorActionPreference$ErrorActionPreference = "Continue"try { return (& $Command | Out-String) } finally { $ErrorActionPreference = $prev }}-# Run the instrumented uninstaller in a child pwsh.function Invoke-Uninstaller([string[]]$ScriptArgs) {$argv = @("-NoProfile", "-File", $uninstallPath) + $ScriptArgs$out = Invoke-Native { & $pwshPath @argv 2>&1 }@@ -60,7 +56,6 @@ function Invoke-Uninstaller([string[]]$ScriptArgs) {}try {- # Both the source and instrumented copy must parse.foreach ($parseCase in @(@{ Name = "source uninstall.ps1"; Path = $sourceUninstallPath },@{ Name = "instrumented uninstall.ps1"; Path = $uninstallPath }