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: include the project config UV_PROJECT sel…
…ects in the mirror gate

install.ps1's Test-MirrorConfigured walks up from UV_PROJECT (resolved against UV_WORKING_DIR) to the first uv.toml or [tool.uv] pyproject.toml; the gate now reads the same file.

[skip ci]
  • Loading branch information
danielhanchen committed Nov 27, 2026
commit 24cbe584898069a766c7761fd4462a9e4cbc78e0
15 changes: 15 additions & 0 deletions studio/backend/tests/test_windows_repair_recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,21 @@ def test_uv_config_precedence_follows_install_ps1(monkeypatch, tmp_path):
assert wr._managed_route_host({"ProgramData": str(system), "UV_NO_SYSTEM_CONFIG": "1"}) is True


@pytest.mark.parametrize("project_file", ["uv.toml", "pyproject.toml"])
def test_an_explicit_uv_project_config_closes_the_route(monkeypatch, tmp_path, project_file):
monkeypatch.setattr(wr._platform, "machine", lambda: "AMD64")
project = tmp_path / "proj"
(project / "sub").mkdir(parents = True)
body = "index-url = 'https://mirror.example/simple'\n"
if project_file == "pyproject.toml":
body = "[tool.uv]\n" + body
(project / project_file).write_text(body, encoding = "utf-8")
# Found walking up from UV_PROJECT, as install.ps1's discovery does.
assert wr._managed_route_host({"UV_PROJECT": str(project / "sub")}) is False
# UV_NO_CONFIG skips it, as it skips every discovered file.
assert wr._managed_route_host({"UV_PROJECT": str(project / "sub"), "UV_NO_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
21 changes: 20 additions & 1 deletion studio/backend/utils/hardware/windows_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def _index_override_leaf(environ = os.environ) -> Optional[str]:
def _uv_config_files(environ) -> list[str]:
"""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."""
UV_NO_SYSTEM_CONFIG, plus the project UV_PROJECT names. Without UV_PROJECT the installer walks its
own working directory, unknown here."""
if environ.get("UV_CONFIG_FILE"):
return [environ["UV_CONFIG_FILE"]]
if str(environ.get("UV_NO_CONFIG", "")).strip().lower() in _UV_TRUE:
Expand All @@ -115,6 +116,24 @@ def _uv_config_files(environ) -> list[str]:
and str(environ.get("UV_NO_SYSTEM_CONFIG", "")).strip().lower() not in _UV_TRUE
):
files.append(os.path.join(environ["ProgramData"], "uv", "uv.toml"))
# An explicit UV_PROJECT names the project the installer's discovery walks up from.
if environ.get("UV_PROJECT"):
base = environ.get("UV_WORKING_DIR") or environ.get("UV_WORKING_DIRECTORY") or os.getcwd()
directory = os.path.abspath(os.path.join(base, environ["UV_PROJECT"]))

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 Discover configs selected by UV_WORKING_DIR without UV_PROJECT

On an otherwise eligible Windows RTX 50-series installation, setting UV_WORKING_DIR (or UV_WORKING_DIRECTORY) to an absolute directory containing a mirror-configured uv.toml, without setting UV_PROJECT, still produces the Repair recommendation. This condition skips project discovery entirely, whereas install.ps1's Test-MirrorConfigured starts discovery from the working-directory override even without UV_PROJECT (install.ps1:4273–4287). The installer consequently rejects the managed 2.13 route and Repair retains the older torch window, leaving the recommendation unresolved. Start discovery from an explicit working-directory override as well as an explicit project.

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 84ee157: discovery now starts from UV_WORKING_DIR / UV_WORKING_DIRECTORY even without UV_PROJECT, and UV_PROJECT and UV_CONFIG_FILE resolve against it, matching Test-MirrorConfigured. New test covers both spellings and fails on 339128d.

while directory:
if os.path.isfile(os.path.join(directory, "uv.toml")):
files.append(os.path.join(directory, "uv.toml"))
break
pyproject = os.path.join(directory, "pyproject.toml")
try:
with open(pyproject, encoding = "utf-8", errors = "replace") as handle:
if re.search(r"^\s*\[+tool\.uv(\.|\])", handle.read(), re.M):
files.append(pyproject)
break
except OSError:
pass
parent = os.path.dirname(directory)
directory = parent if parent != directory else ""
return files

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 Include explicitly selected project configs in the mirror gate

On an otherwise eligible Windows RTX 50-series host, setting UV_PROJECT to an absolute directory containing a mirror-configured uv.toml still produces the Repair recommendation: this helper only returns user/system configs and ignores the selected project. In the inspected Windows installer, Test-MirrorConfigured resolves UV_PROJECT and discovers its configuration (install.ps1:4215–4222), causing Test-PypiUnslothAdmitsTorch to reject the 2.13 route. Repair therefore retains the old torch window and the recommendation persists. Include explicitly selected project configurations in this check; an absolute UV_PROJECT does not require knowing the installer's working directory.

Useful? React with 👍 / 👎.

@danielhanchen danielhanchen Nov 27, 2026 •

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 24cbe58 (my earlier reply named the wrong commit; the change had not been pushed yet). With UV_PROJECT set, and no UV_CONFIG_FILE or UV_NO_CONFIG, the gate walks up from that project like install.ps1: resolved against UV_WORKING_DIR / UV_WORKING_DIRECTORY, it reads the first uv.toml or pyproject.toml with [tool.uv. Covered by test_an_explicit_uv_project_config_closes_the_route.



Expand Down