Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Studio Windows repair hint: read uv config files in install.ps1's pre…
…cedence

UV_CONFIG_FILE is exclusive and UV_NO_CONFIG skips discovery, as Test-MirrorConfigured does.
  • Loading branch information
danielhanchen committed Nov 27, 2026
commit c55eba04409e97a123c43ba75397c7bf3128e0f7
24 changes: 24 additions & 0 deletions studio/backend/tests/test_windows_repair_recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,30 @@ def test_an_index_in_the_uv_config_file_closes_the_route(monkeypatch, tmp_path):
assert wr._managed_route_host({"APPDATA": str(tmp_path)}) is True


def test_uv_config_precedence_follows_install_ps1(monkeypatch, tmp_path):
monkeypatch.setattr(wr._platform, "machine", lambda: "AMD64")
(tmp_path / "uv").mkdir()
(tmp_path / "uv" / "uv.toml").write_text(
"index-url = 'https://mirror.example/simple'\n", encoding = "utf-8"
)
clean = tmp_path / "clean.toml"
clean.write_text("cache-dir = 'D:/uv'\n", encoding = "utf-8")
user = {"APPDATA": str(tmp_path)}
assert wr._managed_route_host(user) is False # the user file names a mirror
# UV_NO_CONFIG skips discovery, and UV_CONFIG_FILE is exclusive: the mirror-free file wins.
assert wr._managed_route_host({**user, "UV_NO_CONFIG": "1"}) is True
assert wr._managed_route_host({**user, "UV_CONFIG_FILE": str(clean)}) is True
assert (
wr._managed_route_host({**user, "UV_CONFIG_FILE": str(clean), "UV_NO_CONFIG": "1"}) is True
)
# A system file is read unless UV_NO_SYSTEM_CONFIG.
system = tmp_path / "sys"
(system / "uv").mkdir(parents = True)
(system / "uv" / "uv.toml").write_text("[[index]]\nurl = 'x'\n", encoding = "utf-8")
assert wr._managed_route_host({"ProgramData": str(system)}) is False
assert wr._managed_route_host({"ProgramData": str(system), "UV_NO_SYSTEM_CONFIG": "1"}) is True


def test_the_mirror_gate_matches_install_ps1():
install = (Path(__file__).resolve().parents[3] / "install.ps1").read_text(encoding = "utf-8")
body = re.search(r"function Test-PypiUnslothAdmitsTorch \{.*?\n \}", install, re.S).group(0)
Expand Down
9 changes: 7 additions & 2 deletions studio/backend/utils/hardware/windows_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ def _index_override_leaf(environ = os.environ) -> Optional[str]:


def _uv_config_files(environ) -> list[str]:
files = []
"""The uv config files install.ps1's Test-MirrorConfigured reads, in its precedence: UV_CONFIG_FILE alone
(even with UV_NO_CONFIG), else none under UV_NO_CONFIG, else the user file plus the system one unless
UV_NO_SYSTEM_CONFIG. Its project discovery walks the installer's working directory, unknown here."""
if environ.get("UV_CONFIG_FILE"):
files.append(environ["UV_CONFIG_FILE"])
return [environ["UV_CONFIG_FILE"]]
if str(environ.get("UV_NO_CONFIG", "")).strip().lower() in _UV_TRUE:
return []
files = []
if environ.get("APPDATA"):
files.append(os.path.join(environ["APPDATA"], "uv", "uv.toml"))
Comment on lines +113 to +119

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor uv configuration precedence when checking mirrors

On an otherwise eligible Windows RTX 50-series installation, a mirror in the user-level uv.toml suppresses the Repair recommendation even when UV_NO_CONFIG=1 disables that file or UV_CONFIG_FILE selects a different, mirror-free configuration. _uv_config_files() always includes the user and system files, whereas install.ps1's Test-MirrorConfigured explicitly makes UV_CONFIG_FILE exclusive and skips configuration discovery under UV_NO_CONFIG. Repair can therefore reach the managed torch in these cases, but the user receives no upgrade hint. Apply the same configuration precedence before inspecting files.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c55eba0: _uv_config_files now follows Test-MirrorConfigured: UV_CONFIG_FILE alone (even with UV_NO_CONFIG), none under UV_NO_CONFIG, else the user file plus the system file unless UV_NO_SYSTEM_CONFIG. Project discovery walks the installer's working directory, which the backend cannot know, so it is not mirrored. Covered by test_uv_config_precedence_follows_install_ps1.

if (
Expand Down