Repository navigation
fix(cli): don't self-upgrade uv tool installs on Windows - #5149
jaeminbird wants to merge 3 commits into
Conversation
`uv tool install --force` deletes the tool environment before reinstalling it. When `specify self upgrade` runs it from that environment on Windows, uv removes Lib\site-packages and then fails on Scripts\ because the running python.exe is locked, leaving `specify` without its package. When the running interpreter is a uv tool environment on Windows, print the uv command to run once specify exits and make no changes. pipx installs and other platforms are unchanged. Fixes github#5141 Assisted-by: Claude Code (model: Claude Opus 5.5, supervised)
|
Please address Copilot feedback |
On Windows, a real `specify self upgrade` from a uv tool environment prints the uv command instead of running it, but `--dry-run` still listed that command as the one that would be executed. Preview the same outcome, printing the command to run once specify exits exactly as the real run does, and add the Windows exception to the `--help` text. Refs github#5141 Assisted-by: Claude Code (model: Claude Opus 5.5, supervised)
|
@mnriem Addressed both Copilot points in dcc351b:
|
There was a problem hiding this comment.
🟡 Changes recommended
The upgrade guidance omits a warning to stop all processes using the uv tool environment, so following the printed command can still encounter Windows file locks and partially delete the installation.
1 open issue
2 resolved since last review
Review effort: Max
| "running from. No changes were made.", | ||
| soft_wrap=True, | ||
| ) | ||
| console.print("Run it yourself once this command exits:", soft_wrap=True) |
|
Please address Copilot feedback |
Exiting `specify self upgrade` does not release the Windows lock on the tool environment's python.exe if another process from it is still running, such as an editor's `specify mcp` server. Running the printed uv command then fails partway through the same way. Say to stop those processes first, in both the real run and --dry-run output and in docs/upgrade.md. Refs github#5141 Assisted-by: Claude Code (model: Claude Opus 5.5, autonomous)
|
@mnriem Addressed the remaining Copilot point in 68e38e9: the Windows uv tool guidance (real run, Posted on behalf of @jaeminbird by Claude Code (Claude Opus 5.5, autonomous); the fix, tests and this comment are agent-authored. |
|
Please address Copilot feedback |

Description
Fixes #5141
On Windows,
specify self upgradeon a uv tool install runsuv tool install --forcefrom inside that tool environment. uv deletesLib\site-packages, then fails onScripts\because the runningpython.exeis locked, leavingspecifywithout its package; the "Try again" hint can't work after that.When the running interpreter is a uv tool env on Windows (
os.name == "nt"anduv-receipt.tomlinsys.prefix), the command now makes no changes and prints the uv command to run once specify exits: the fail-closed fallback from the bug assessment. A hand-off after exit can't stop the nextspecifylaunch from re-locking the env and can't report uv's result; microsoft/conductor#171 landed on the same approach. pipx, POSIX, already-latest and invalid-tag behaviour unchanged.Windows 11, uv 0.13.5, isolated
UV_TOOL_DIR/UV_TOOL_BIN_DIR, installed from v1.2.2:main:
This PR (v1.2.2 + fix):
Running the printed command (Git Bash, PowerShell 5.1) gives a working 1.2.4.
Testing
uv run specify --helpuv sync && uv run pytestNew
TestWindowsUvToolEnvironmentintests/specify_cli/test_version_execution.py; command test fails on main, passes w/ fix. Dev HEAD bare upgrade,--tag v1.2.5.dev0,--tag latest,--dry-runand pipx (isolatedPIPX_HOME) same before/after;--tag v1.2.4from dev HEAD breaks the install on main, stopped here.uv run pytest -n auto: Linux py3.14 same 2 root-only failures as main; Windows py3.14 no new failures.uvx ruff@0.15.0 check src tests, markdownlint ondocs/upgrade.md: pass.AI Disclosure
AI disclosure: Claude Code (Claude Opus 5.5, default settings, human-supervised) reproduced the bug and wrote the fix and tests (code generation); results verified on Windows 11 as shown above.