Skip to content

Installer: do not blame a verified uv for a destination it could not replace - #11081

Closed
lonexreb wants to merge 11 commits into
unslothai:mainfrom
lonexreb:fix/installer-uv-in-use
Closed

lonexreb wants to merge 11 commits into
unslothai:mainfrom
lonexreb:fix/installer-uv-in-use

Conversation

@lonexreb

Copy link
Copy Markdown
Contributor

Refs #9804 (the uv half; #9924 covers the launcher verdict).

What

Install-UvFromRelease downloads the pinned uv, proves it runs (Get-UvExecutableVerdict), and only then copies uv.exe / uvx.exe / uvw.exe over the existing set. With a uv still running, as in the report, Windows refuses that overwrite: the copy loop set $ok = $false and the installer printed

the downloaded uv 0.12.1 could not run on this machine.

which is the one thing it had just proven false, and exited. The reporter got past it only by finding and closing the process holding uv.

How

The copy moves into Copy-UvSet (with a Test-UvFileMatches hash helper):

  • A destination already holding the verified bytes is left alone. The uv this installer is "replacing" may be that very build, still running; there is nothing to replace, so the lock does not matter.
  • A copy that fails is retried three times over ~750 ms, for a scanner that opens a fresh download (the same shape as Remove-StudioVenvTreeWithRetry).
  • Every copy is verified against the staged file, not only uv.exe as before (Copy-Item is non-terminating under some callers' preference, and a stale binary must not pass for ours).
  • A real lock records the file in $script:UvCopyBlockedAt, and the caller says so:
uv 0.12.1 downloaded and verified, but C:\Users\me\.local\bin\uv.exe could not be replaced.
It is probably in use (a running uv, or a scanner); close it and re-run the installer.

The verdict probe keeps its own "could not run" message; the copy no longer borrows it. Deliberately NOT changed: Test-UvCandidateVersion's no-"unknown"-verdict gate that @Sletch raised on the issue. The report's own steps pin the replacement, not the gate, and treating a throwing probe as not-broken decides which uv every later install command runs through, which deserves its own evidence.

Verification

  • tests/test_installer_uv_in_use.py: text pins for the skip-before-copy order, the retry, and the named lock (pass locally). Three pwsh cases run Copy-UvSet verbatim, holding the destination open exclusively the way a running executable's image is: an identical locked uv.exe is left alone and the call succeeds; a differing locked uv.exe is reported by path and not half-written. These need pwsh, so they run on the CI legs that have it (skipped here, no pwsh on this host).
  • Existing installer suites (tests/test_installer_*.py, test_studio_install_workspace_guard.py): 441 passed, 53 skipped. tests/sh/test_uv_pinned_release.sh: all 71 install.ps1 pins pass; its one local failure is the install.sh hang probe timing out on a host without timeout, same before this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd

@lonexreb

This comment has been minimized.

@lonexreb
lonexreb force-pushed the fix/installer-uv-in-use branch from 03204e7 to a6b68bc Compare September 16, 2026 08:51
@lonexreb

This comment has been minimized.

@lonexreb

This comment has been minimized.

@lonexreb
lonexreb force-pushed the fix/installer-uv-in-use branch 2 times, most recently from 961cf5a to 12ff66b Compare September 16, 2026 14:57
@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the copy failure in install.ps1 still borrows the verdict probe's "could not run on this machine" wording, and the extracted Copy-UvSet skip-if-identical plus named lock path looks right. Will get this reviewed.

lonexreb and others added 5 commits September 26, 2026 18:12
…replace

Install-UvFromRelease downloads the pinned uv, proves it runs, and then
copies the set over the existing one. With a uv still running (unslothai#9804)
Windows refuses that overwrite; the copy loop set $ok = $false and the
installer reported "the downloaded uv could not run on this machine",
the one thing it had just proven false, then exited.

The copy moves into Copy-UvSet:

- a destination already holding the verified bytes is left alone, since
  the running uv this installer is "replacing" may be that very build;
- a copy that fails is retried three times over ~750 ms, for a scanner
  that opens a fresh download;
- every copy is verified against the staged file (Copy-Item is
  non-terminating under some callers' preference), not only uv.exe;
- a real lock names the file in $script:UvCopyBlockedAt, and the caller
  says it is probably in use and to close it and re-run.

The verdict probe keeps its own "could not run" message; the copy no
longer borrows it. Test-UvCandidateVersion is unchanged.

tests/test_installer_uv_in_use.py: text pins for the skip-before-copy
order, the retry and the named lock; pwsh cases run Copy-UvSet verbatim
with a destination held open exclusively, asserting an identical locked
file is left alone and a differing locked file is reported and not
half-written. Existing installer suites: 441 passed; the uv pinned
release pins: 71 passed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd
tests/python/test_cross_platform_parity.py pins that the extracted
uv.exe is probed before anything at the destination is touched by
requiring the probe call to precede the first Copy-Item in the file.
Copy-UvSet sat above Install-UvFromRelease, so its Copy-Item came
first in the text although it runs after the probe. Defined below the
installer now, still ahead of the call site; no behaviour change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd
…unning uv really holds

The first behaviour case copied into a destination directory it never
created, which Install-UvFromRelease always does before Copy-UvSet. The
identical-locked case opened the destination with share None, which
refuses even the hash read; a running executable's image on Windows
admits readers and refuses writers, so the case now shares Read, and
Copy-UvSet's hash sees the file is already ours without writing.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd
main unpacks the uv archive under $srcRoot (a subfolder when the release
carries one) before probing the staged binary, so Copy-UvSet reads from
there; the pin names that variable.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd
@lonexreb

This comment has been minimized.

lonexreb and others added 3 commits September 30, 2026 23:08
…ow reaches

test_mirror_fallback.ps1 runs Install-UvFromRelease from install.ps1's AST
with the helpers it calls stubbed or loaded by name. This branch moved the
copy into Copy-UvSet and Test-UvFileMatches, which the list did not name,
so the suite died at the call with "Copy-UvSet is not recognized". Load the
real ones: they skip files the fixture lacks and copy the rest, which is
exactly what the assertions on the destination expect.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd
@lonexreb

This comment has been minimized.

@danielhanchen danielhanchen self-assigned this Oct 4, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Does not actually fix the linked issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants