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.

Repair the studio-install checks red on main (#14995)

Daniel Han4af53cbd9348
diff --git a/install.ps1 b/install.ps1
index 146bd82f98a..218e1668bd2 100644
--- a/install.ps1
+++ b/install.ps1
@@ -4576,17 +4576,15 @@ function Install-UnslothStudio {
$pattern = '^\s*(\[\[(tool\.uv\.)?index\]\]|(pip\.)?(index|index-url|default-index|extra-index-url|no-index)\s*=)'
}
# uv's discovery: UV_CONFIG_FILE alone (even with UV_NO_CONFIG); relative paths from --directory.
- # uv's bool parser (Test-UvEnvFlag), inlined: setup.ps1 reaches this before it defines that helper.
- $uvTrue = @('1', 't', 'true', 'y', 'yes', 'on')
$files = @("$env:APPDATA\uv\uv.toml")
- if ($uvTrue -notcontains "$env:UV_NO_SYSTEM_CONFIG".Trim().ToLowerInvariant()) { $files += "$env:ProgramData\uv\uv.toml" }
+ if (-not (Test-UvEnvFlag 'UV_NO_SYSTEM_CONFIG')) { $files += "$env:ProgramData\uv\uv.toml" }
$dir = (Get-Location -PSProvider FileSystem).ProviderPath
$workDir = if ($env:UV_WORKING_DIR) { $env:UV_WORKING_DIR } else { $env:UV_WORKING_DIRECTORY }
if ($workDir) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $workDir)) }
$configFile = if ($env:UV_CONFIG_FILE) { [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $env:UV_CONFIG_FILE)) }
if ($env:UV_PROJECT) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $env:UV_PROJECT)) }
if ($configFile) { $files = @($configFile); $dir = $null }
- elseif ($uvTrue -contains "$env:UV_NO_CONFIG".Trim().ToLowerInvariant()) { $files = @(); $dir = $null }
+ elseif (Test-UvEnvFlag 'UV_NO_CONFIG') { $files = @(); $dir = $null }
while ($dir) {
$pyproject = Join-Path $dir 'pyproject.toml'
if (Test-Path -LiteralPath (Join-Path $dir 'uv.toml') -PathType Leaf) { $files += Join-Path $dir 'uv.toml'; break }
diff --git a/studio/setup.ps1 b/studio/setup.ps1
index 7af6d8d61a6..39aba4b0151 100644
--- a/studio/setup.ps1
+++ b/studio/setup.ps1
@@ -1083,6 +1083,48 @@ function Invoke-ManagedLlamaCppPreflight {
return "$reason Nothing was installed."
}
+# uv's own boolish set, for every UV_* switch this script reads out of the caller's
+# environment. Verified against uv 0.10.7, crates/uv-static/src/lib.rs
+# parse_boolish_environment_variable, which restates clap's str_to_bool: true is
+# y, yes, t, true, on, 1; false is n, no, f, false, off, 0; case-insensitive, and
+# anything else aborts uv rather than being guessed at.
+#
+# `-notin @("", "0", "false")`, which each of these sites used to spell inline, read
+# off, no, n and f as TRUE, the exact opposite of uv's answer for them.
+#
+# Trimmed where uv is not: uv aborts on a padded value, so the resolve fails whatever
+# this returns, and trimming keeps the answer identical to setup.sh's
+# _uv_offline_requested and install_python_stack.py's _uv_env_flag, which is the
+# property worth having. ToLowerInvariant, not ToLower: a Turkish-locale host
+# lowercases "I" to a dotless i and would stop matching.
+#
+# install.ps1 carries the same function: the two scripts cannot dot-source each other
+# (install.ps1 is run straight off the wire by `irm | iex`, with no file and no sibling
+# on disk), so the parity is pinned by test instead. Defined ahead of Test-MirrorConfigured,
+# which `Invoke-MirrorFallback -SpareOnly` reaches long before the rest of the helpers.
+function Test-UvEnvFlag {
+ param([string]$Name)
+ $value = [string][Environment]::GetEnvironmentVariable($Name)
+ return (@("1", "t", "true", "y", "yes", "on") -contains $value.Trim().ToLowerInvariant())
+}
+
+# pip's rule, kept separate on purpose: PIP_NO_INDEX is pip's variable and uv never
+# reads it, so uv's parser has no authority over it. pip routes it through
+# ConfigOptionParser._update_defaults -> strtobool (pip/_internal/utils/misc.py): true
+# is y, yes, t, true, on, 1; false is n, no, f, false, off, 0; case-insensitive and
+# untrimmed, with anything else exiting pip on "is not a valid value". An empty value
+# never reaches strtobool, because _get_ordered_configuration_items drops falsy values
+# first, so PIP_NO_INDEX="" is simply not set.
+#
+# The literals coincide with uv's today. They are restated rather than shared anyway,
+# so that the day either project changes its mind this is a one-function edit instead
+# of a silent behaviour change in the other resolver.
+function Test-PipEnvFlag {
+ param([string]$Name)
+ $value = [string][Environment]::GetEnvironmentVariable($Name)
+ return (@("1", "t", "true", "y", "yes", "on") -contains $value.Trim().ToLowerInvariant())
+}
+
function Test-MirrorConfigured {
param([ValidateSet('uv', 'python', 'pip')][string]$Tool)
if ($Tool -ne 'pip') {
@@ -1095,17 +1137,15 @@ function Test-MirrorConfigured {
$pattern = '^\s*(\[\[(tool\.uv\.)?index\]\]|(pip\.)?(index|index-url|default-index|extra-index-url|no-index)\s*=)'
}
# uv's discovery: UV_CONFIG_FILE alone (even with UV_NO_CONFIG); relative paths from --directory.
- # uv's bool parser (Test-UvEnvFlag), inlined: setup.ps1 reaches this before it defines that helper.
- $uvTrue = @('1', 't', 'true', 'y', 'yes', 'on')
$files = @("$env:APPDATA\uv\uv.toml")
- if ($uvTrue -notcontains "$env:UV_NO_SYSTEM_CONFIG".Trim().ToLowerInvariant()) { $files += "$env:ProgramData\uv\uv.toml" }
+ if (-not (Test-UvEnvFlag 'UV_NO_SYSTEM_CONFIG')) { $files += "$env:ProgramData\uv\uv.toml" }
$dir = (Get-Location -PSProvider FileSystem).ProviderPath
$workDir = if ($env:UV_WORKING_DIR) { $env:UV_WORKING_DIR } else { $env:UV_WORKING_DIRECTORY }
if ($workDir) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $workDir)) }
$configFile = if ($env:UV_CONFIG_FILE) { [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $env:UV_CONFIG_FILE)) }
if ($env:UV_PROJECT) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $env:UV_PROJECT)) }
if ($configFile) { $files = @($configFile); $dir = $null }
- elseif ($uvTrue -contains "$env:UV_NO_CONFIG".Trim().ToLowerInvariant()) { $files = @(); $dir = $null }
+ elseif (Test-UvEnvFlag 'UV_NO_CONFIG') { $files = @(); $dir = $null }
while ($dir) {
$pyproject = Join-Path $dir 'pyproject.toml'
if (Test-Path -LiteralPath (Join-Path $dir 'uv.toml') -PathType Leaf) { $files += Join-Path $dir 'uv.toml'; break }
@@ -6712,47 +6752,6 @@ function Read-WoaUvTomlIndexKeys {
return @{ NoIndex = $noIndex; DefaultIndex = $defaultIndex; ExtraIndexes = @($extras | Where-Object { $_ }) }
}
-# uv's own boolish set, for every UV_* switch this script reads out of the caller's
-# environment. Verified against uv 0.10.7, crates/uv-static/src/lib.rs
-# parse_boolish_environment_variable, which restates clap's str_to_bool: true is
-# y, yes, t, true, on, 1; false is n, no, f, false, off, 0; case-insensitive, and
-# anything else aborts uv rather than being guessed at.
-#
-# `-notin @("", "0", "false")`, which each of these sites used to spell inline, read
-# off, no, n and f as TRUE, the exact opposite of uv's answer for them.
-#
-# Trimmed where uv is not: uv aborts on a padded value, so the resolve fails whatever
-# this returns, and trimming keeps the answer identical to setup.sh's
-# _uv_offline_requested and install_python_stack.py's _uv_env_flag, which is the
-# property worth having. ToLowerInvariant, not ToLower: a Turkish-locale host
-# lowercases "I" to a dotless i and would stop matching.
-#
-# install.ps1 carries the same function: the two scripts cannot dot-source each other
-# (install.ps1 is run straight off the wire by `irm | iex`, with no file and no sibling
-# on disk), so the parity is pinned by test instead.
-function Test-UvEnvFlag {
- param([string]$Name)
- $value = [string][Environment]::GetEnvironmentVariable($Name)
- return (@("1", "t", "true", "y", "yes", "on") -contains $value.Trim().ToLowerInvariant())
-}
-
-# pip's rule, kept separate on purpose: PIP_NO_INDEX is pip's variable and uv never
-# reads it, so uv's parser has no authority over it. pip routes it through
-# ConfigOptionParser._update_defaults -> strtobool (pip/_internal/utils/misc.py): true
-# is y, yes, t, true, on, 1; false is n, no, f, false, off, 0; case-insensitive and
-# untrimmed, with anything else exiting pip on "is not a valid value". An empty value
-# never reaches strtobool, because _get_ordered_configuration_items drops falsy values
-# first, so PIP_NO_INDEX="" is simply not set.
-#
-# The literals coincide with uv's today. They are restated rather than shared anyway,
-# so that the day either project changes its mind this is a one-function edit instead
-# of a silent behaviour change in the other resolver.
-function Test-PipEnvFlag {
- param([string]$Name)
- $value = [string][Environment]::GetEnvironmentVariable($Name)
- return (@("1", "t", "true", "y", "yes", "on") -contains $value.Trim().ToLowerInvariant())
-}
-
# UV_NO_INDEX is OURS, not uv's, and the distinction is not pedantic: uv 0.10.7 defines
# no such environment variable. `--no-index` exists only as a command-line flag, it is
# absent from `uv pip install --help`'s environment list beside UV_OFFLINE and
diff --git a/tests/studio/install/test_rocm_native_linux_lib_dirs.py b/tests/studio/install/test_rocm_native_linux_lib_dirs.py
index abece4be038..2aa5650b3ef 100644
--- a/tests/studio/install/test_rocm_native_linux_lib_dirs.py
+++ b/tests/studio/install/test_rocm_native_linux_lib_dirs.py
@@ -6,6 +6,7 @@
import ast
import importlib.util
import os
+import re
import sys
from pathlib import Path
from unittest.mock import patch
@@ -455,14 +456,19 @@ class TestLlamaCppRuntimeNativeOrdering:
def test_prepends_before_binary_dir(self):
source = _LLAMA_CPP_PATH.read_text(encoding = "utf-8")
- idx_helper = source.find("lib_dirs.extend(_native_linux_system_rocm_lib_dirs(binary_dir))")
- idx_binary = source.find("lib_dirs.append(binary_dir)")
+ idx_helper = source.find("_native_linux_system_rocm_lib_dirs(binary_dir)")
assert (
idx_helper != -1
), "serve-time launcher must call the native-Linux helper with binary_dir"
- assert idx_binary != -1
+ # #14933 holds the result in a local so it can drop it when it hides the GPU.
+ call = source[source.rfind("\n", 0, idx_helper) : source.find("\n", idx_helper)]
+ held = re.match(r"\s*(\w+)\s*=\s*_native_linux_system_rocm_lib_dirs", call)
+ extend = f"lib_dirs.extend({held.group(1)})" if held else "lib_dirs.extend("
+ idx_extend = source.find(extend, idx_helper)
+ idx_binary = source.find("lib_dirs.append(binary_dir)", idx_helper)
+ assert idx_extend != -1 and idx_binary != -1
assert (
- idx_helper < idx_binary
+ idx_helper < idx_extend < idx_binary
), "system ROCm must be searched before the bundled HIP runtime"
def test_dxg_detection_stays_on_the_wsl_branch(self):
@@ -470,7 +476,7 @@ class TestLlamaCppRuntimeNativeOrdering:
source = _LLAMA_CPP_PATH.read_text(encoding = "utf-8")
idx_wsl = source.find("lib_dirs.extend(_wsl_system_rocm_lib_dirs())")
idx_dxg = source.find('env.setdefault("HSA_ENABLE_DXG_DETECTION", "1")', idx_wsl)
- idx_native = source.find("lib_dirs.extend(_native_linux_system_rocm_lib_dirs(binary_dir))")
+ idx_native = source.find("_native_linux_system_rocm_lib_dirs(binary_dir)")
assert idx_wsl != -1 and idx_dxg != -1 and idx_native != -1
assert idx_wsl < idx_dxg < idx_native, (
"HSA_ENABLE_DXG_DETECTION must be decided from the WSL dirs alone, before the "
diff --git a/tests/studio/install/test_uv_boolish_parity.py b/tests/studio/install/test_uv_boolish_parity.py
index 8b1356e973f..37d20cea047 100644
--- a/tests/studio/install/test_uv_boolish_parity.py
+++ b/tests/studio/install/test_uv_boolish_parity.py
@@ -487,3 +487,13 @@ def test_a_no_index_set_to_a_false_value_still_names_an_index(script, variable,
got = _ps_last(snippet, env = _env(variable, value))
assert got != "[]", f"{variable}={value!r} is false, so an index must still be named"
assert "https://pypi.org/simple" in got, got
+
+
+def test_setup_defines_the_uv_reader_before_its_first_mirror_probe():
+ """A PowerShell function exists only once its definition has run. setup.ps1 probes mirrors
+ (Test-MirrorConfigured reads UV_NO_CONFIG) from `Invoke-MirrorFallback -SpareOnly` early on,
+ so a reader defined later is undefined there, which is what pushed a copy of it inline."""
+ define = re.search(r"(?m)^function Test-UvEnvFlag\b", SETUP_SRC)
+ first_call = re.search(r"(?m)^Invoke-MirrorFallback\b", SETUP_SRC)
+ assert define and first_call
+ assert define.start() < first_call.start()