fix(update): retry the Windows self-update in copy link mode after a hardlink error (#786) - #789
Merged
Merged
Conversation
…786) On Windows, uv's default hardlink mode fails with os error 396 when the uv cache or tool dir sits on a cloud-synced volume (OneDrive), after --force --reinstall already removed the old tool venv -- kbagent vanished. Every uv tool install kbagent builds on Windows, and the printed recovery command, now pass --link-mode copy unless UV_LINK_MODE is set. POSIX command lines are unchanged.
The first version added --link-mode copy to every Windows self-update install. That made the update slower for every Windows user. The install now keeps the default uv link mode. The background helper runs the install once more with --link-mode copy only if the first install failed and uv printed "failed to hardlink file". The match is case-sensitive. uv also prints a warning when its own fallback to copy works. That warning does not match. The printed recovery command keeps copy mode.
soustruh
marked this pull request as ready for review
September 25, 2026 19:35
soustruh
requested review from
keboola-pr-reviewer-bot and
soustruh
as code owners
September 25, 2026 19:35
keboola-pr-reviewer-bot
approved these changes
Sep 25, 2026
keboola-pr-reviewer-bot
left a comment
There was a problem hiding this comment.
Verdict: auto_approve (risk 2/5) · profile keboola-mcp-server
duplicate-not-used
soustruh
approved these changes
Sep 25, 2026
soustruh
left a comment
Contributor
There was a problem hiding this comment.
Changed the approach: the install keeps the default uv link mode, and copy mode runs only as a retry after a hardlink error. Windows users whose disks can hardlink keep the faster update. The description is updated to match.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On Windows, the self-update keeps the default uv link mode (hardlink). If the install fails and the uv output contains
failed to hardlink file, the background helper runs the same install once more with--link-mode copy. The logpending_update.logcontains the output of both attempts.The recovery command that kbagent prints after a failure also includes
--link-mode copy. If the user setUV_LINK_MODE, kbagent adds no retry and no flag. POSIX command lines do not change.Why
In #786, the background self-update failed with uv
os error 396(ERROR_CLOUD_FILE_INCOMPATIBLE_HARDLINKS). The uv cache or the tool directory was on a cloud-synced volume (OneDrive Files-On-Demand). That volume cannot hardlink between the two paths.uv tool install --force --reinstallremoves the old tool venv before it creates the new one. When the install failed, kbagent was gone. The printed recovery command failed in the same way. The reporter confirmed that the same command works withUV_LINK_MODE=copy.Copy mode is slower than hardlinks and uses more disk space. With copy mode on every update, the update is slower for every Windows user. Only users with a cloud-synced setup need copy mode, so the retry runs only after a failure.
The match is case-sensitive. uv prints
warning: Failed to hardlink files; falling back to full copywhen its own fallback works. That warning must not start a retry. The matched text comes from the error line, where it is lowercase:Caused by: failed to hardlink file from ... (os error 396).Testing
make checkpasses: lint, format,ty, version gates, command sync and the full test suite.tests/test_update_runner.py: the helper script contains the retry only when the request has a retry command. The retry comes after the first attempt and before the log write.tests/test_version_service.py:--link-mode.--link-mode copybefore the package spec.UV_LINK_MODEproduce no retry command.--link-mode copyone time.Not in this PR
kbagentcall in the same session. The reporter saw three identical failures, one after another.UV_LINK_MODE=copybefore they update.This PR uses
Refs #786, notFixes. The issue stays open for the atomic install.Refs #786