Skip to content

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.

Windows install: keep typer below 0.29 so studio setup does not hold pydantic_core open (#17319)

Daniel Hanf3ebd4869391
diff --git a/install.ps1 b/install.ps1
index d105128a0e4..681adedb19f 100644
--- a/install.ps1
+++ b/install.ps1
@@ -9946,6 +9946,9 @@ main()
$_unslothDesktopInstallSpec = if ($_desktopMinVer) { "unsloth>=$_desktopMinVer" } else { $null }
$_unslothReleaseInstallSpec = if ($_unslothDesktopInstallSpec) { $_unslothDesktopInstallSpec } else { "unsloth>=2026.11.3" }
$_unslothZooInstallSpec = "unsloth-zoo>=2026.11.3"
+ # typer 0.29 imports pydantic, so `unsloth studio setup` would hold pydantic_core's .pyd open while
+ # the Studio requirements re-pin pydantic, and Windows refuses to replace a loaded .pyd.
+ $_typerCapSpec = "typer<0.29"
# Twin of install.sh's _relax_unsloth_floors_to_index (#14031).
function Resolve-NoTorchPair {
@@ -10132,7 +10135,7 @@ print(*pair)
$script:TorchOverridesFile = New-UnslothTorchOverridesFile -PythonExe $VenvPython
$_migOverrides = @()
if ($script:TorchOverridesFile) { $_migOverrides = @("--overrides", $script:TorchOverridesFile) }
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (migrated)" { & $script:UvExe pip install --python $VenvPython @_migOverrides --reinstall-package unsloth --reinstall-package unsloth-zoo "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (migrated)" { & $script:UvExe pip install --python $VenvPython @_migOverrides --reinstall-package unsloth --reinstall-package unsloth-zoo "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" "$_typerCapSpec" }
if ($script:TorchOverridesFile) {
Remove-UnslothTempFileQuietly -Path $script:TorchOverridesFile
$script:TorchOverridesFile = $null
@@ -10411,21 +10414,21 @@ print(*pair)
# Freeze the trio so this with-deps resolve cannot downgrade the pinned build.
$script:TorchOverridesFile = New-UnslothTorchOverridesFile -PythonExe $VenvPython
if ($script:TorchOverridesFile) {
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (local)" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth --overrides $script:TorchOverridesFile "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (local)" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth --overrides $script:TorchOverridesFile "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" "$_typerCapSpec" }
Remove-UnslothTempFileQuietly -Path $script:TorchOverridesFile
$script:TorchOverridesFile = $null
} else {
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (local)" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (local)" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" "$_typerCapSpec" }
}
} else {
$_unslothPkg = if ($PackageName -eq "unsloth" -and $_unslothDesktopInstallSpec) { $_unslothDesktopInstallSpec } else { $PackageName }
$script:TorchOverridesFile = New-UnslothTorchOverridesFile -PythonExe $VenvPython
if ($script:TorchOverridesFile) {
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth --overrides $script:TorchOverridesFile -- "$_unslothPkg" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth --overrides $script:TorchOverridesFile -- "$_unslothPkg" "$_typerCapSpec" }
Remove-UnslothTempFileQuietly -Path $script:TorchOverridesFile
$script:TorchOverridesFile = $null
} else {
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth -- "$_unslothPkg" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth -- "$_unslothPkg" "$_typerCapSpec" }
}
}
if ($baseInstallExit -ne 0) {
@@ -10452,7 +10455,7 @@ print(*pair)
Write-TauriLog "STEP" "Installing unsloth"
substep "installing unsloth (this may take a few minutes)..."
if ($StudioLocalInstall) {
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (auto torch backend)" { & $script:UvExe pip install --python $VenvPython "$_unslothZooInstallSpec" "$_unslothReleaseInstallSpec" --torch-backend=auto }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (auto torch backend)" { & $script:UvExe pip install --python $VenvPython "$_unslothZooInstallSpec" "$_unslothReleaseInstallSpec" "$_typerCapSpec" --torch-backend=auto }
if ($baseInstallExit -ne 0) {
Write-StudioLine "[ERROR] Failed to install unsloth (exit code $baseInstallExit)" -ForegroundColor Red
return (Exit-InstallFailure "Failed to install unsloth (exit code $baseInstallExit)" $baseInstallExit)
@@ -10471,7 +10474,7 @@ print(*pair)
}
} else {
$_unslothPkg = if ($PackageName -eq "unsloth" -and $_unslothDesktopInstallSpec) { $_unslothDesktopInstallSpec } else { $PackageName }
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (auto torch backend)" { & $script:UvExe pip install --python $VenvPython --torch-backend=auto -- "$_unslothPkg" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (auto torch backend)" { & $script:UvExe pip install --python $VenvPython --torch-backend=auto -- "$_unslothPkg" "$_typerCapSpec" }
if ($baseInstallExit -ne 0) {
Write-StudioLine "[ERROR] Failed to install unsloth (exit code $baseInstallExit)" -ForegroundColor Red
return (Exit-InstallFailure "Failed to install unsloth (exit code $baseInstallExit)" $baseInstallExit)
diff --git a/pyproject.toml b/pyproject.toml
index dff6edda9e0..f5b8e16e262 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -30,7 +30,9 @@ classifiers = [
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dependencies = [
- "typer>=0.19.0",
+ # typer 0.29 imports pydantic, so the running `unsloth studio setup` would hold pydantic_core's
+ # .pyd open on Windows while the Studio requirements re-pin pydantic, and the swap fails.
+ "typer>=0.19.0,<0.29",
"rich",
"pydantic",
"pyyaml",
diff --git a/studio/backend/requirements/no-torch-runtime.txt b/studio/backend/requirements/no-torch-runtime.txt
index 02d42669bfd..7e5d773e693 100644
--- a/studio/backend/requirements/no-torch-runtime.txt
+++ b/studio/backend/requirements/no-torch-runtime.txt
@@ -7,7 +7,8 @@
# metadata still declares torch as a hard dep).
# unsloth direct deps (from pyproject.toml [project].dependencies)
-typer>=0.19.0
+# Capped below 0.29, which imports pydantic: see pyproject.toml.
+typer>=0.19.0,<0.29
click>=8.0
rich>=13.0
# typer's remaining runtime dep tree, needed explicitly under --no-deps.
diff --git a/tests/test_typer_cap_keeps_setup_pydantic_free.py b/tests/test_typer_cap_keeps_setup_pydantic_free.py
new file mode 100644
index 00000000000..e20ffc84607
--- /dev/null
+++ b/tests/test_typer_cap_keeps_setup_pydantic_free.py
@@ -0,0 +1,46 @@
+"""typer 0.29 imports pydantic. `unsloth studio setup` runs as a typer CLI, so with typer 0.29 it holds
+pydantic_core's native module open while the Studio requirements re-pin pydantic, and Windows refuses to
+replace a loaded .pyd ("Access is denied"). Every install that runs before setup keeps typer below 0.29.
+"""
+
+from __future__ import annotations
+
+import re
+import tomllib
+from pathlib import Path
+
+from packaging.requirements import Requirement
+
+ROOT = Path(__file__).resolve().parents[1]
+FIRST_PYDANTIC_TYPER = "0.29.0"
+
+
+def _typer(requirements):
+ found = [Requirement(r) for r in requirements if re.match(r"\s*typer\b", r)]
+ assert len(found) == 1, requirements
+ return found[0]
+
+
+def test_the_package_dependency_keeps_typer_below_the_pydantic_release():
+ project = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding = "utf-8"))["project"]
+ req = _typer(project["dependencies"])
+ assert FIRST_PYDANTIC_TYPER not in req.specifier, req
+
+
+def test_the_no_torch_runtime_keeps_typer_below_the_pydantic_release():
+ path = ROOT / "studio" / "backend" / "requirements" / "no-torch-runtime.txt"
+ lines = [l.split("#", 1)[0].strip() for l in path.read_text(encoding = "utf-8").splitlines()]
+ req = _typer([l for l in lines if l])
+ assert FIRST_PYDANTIC_TYPER not in req.specifier, req
+
+
+def test_every_resolving_base_install_in_install_ps1_carries_the_cap():
+ source = (ROOT / "install.ps1").read_text(encoding = "utf-8")
+ cap = re.search(r'^\s*\$_typerCapSpec\s*=\s*"([^"]+)"', source, re.M)
+ assert cap, "install.ps1 no longer defines $_typerCapSpec"
+ assert FIRST_PYDANTIC_TYPER not in Requirement(cap.group(1)).specifier, cap.group(1)
+ installs = re.findall(r'-Label "install unsloth[^"]*" \{([^\n]*)\}', source)
+ resolving = [cmd for cmd in installs if "--no-deps" not in cmd]
+ assert len(resolving) >= 4, installs
+ missing = [cmd.strip() for cmd in resolving if '"$_typerCapSpec"' not in cmd]
+ assert not missing, missing