Make the uv bootstrap chain survive venv recreation#19
Open
Anmolnoor wants to merge 1 commit into
Open
Conversation
A Homebrew Python upgrade (3.12.12 -> 3.12.13) made uv recreate .venv against the lockfile, which removed the unlocked pip and uv binaries: ./scripts/uv hard-requires .venv/bin/uv, and bootstrap.sh assumed .venv/bin/pip exists whenever .venv does, so its recovery path crashed at 'pip install uv' and the user was stuck. Declare pip and uv as dev dependencies so every sync keeps them in the venv, teach bootstrap.sh to rebuild a venv that has neither binary, and add a contract test so they cannot be dropped from the dev extras again. Verified end-to-end: bootstrap heals the broken venv, and an exact 'uv sync --extra dev' no longer strips either binary. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
After Homebrew upgraded Python 3.12.12 → 3.12.13, uv recreated
.venvto match the lockfile exactly — which removed the unlockedpipanduvbinaries. That broke both ends of the bootstrap chain:foundation(the shell alias →./scripts/uv) failed withMissing .venv/bin/uv. Run ./scripts/bootstrap.sh first../scripts/bootstrap.shcrashed at line 150 (.venv/bin/pip: No such file or directory) because it only creates the venv when the directory is entirely missing, then assumes pip exists.So the documented recovery path could not recover.
Fix (root cause, three parts)
pipanduvas dev dependencies (with a comment explaining why) —uv syncmakes the environment exactly match the lockfile, so the only way the wrapper's.venv/bin/uvsurvives syncs and interpreter-upgrade recreations is to be in the lockfile. This also makes the system self-healing: after a future interpreter upgrade, the still-workinguvbinary re-syncs and reinstalls itself into the fresh venv.bootstrap.shto rebuild a venv that has neither pip nor uv (python -m venv --clear), so it can recover from the exact state users hit.tests/test_dev_env_contract.py) assertinguvandpipstay in the dev extras — fails before the fix, passes after, and stops anyone from quietly resurrecting the footgun.Verification
./scripts/uv run …→ "Missing .venv/bin/uv", bootstrap → pip not found)../scripts/bootstrap.shrun end-to-end on the broken venv: rebuilds it, installs uv, syncs — exit 0../scripts/uv run foundation --help(the alias path) works again../scripts/uv sync --extra devkeepspipanduv(this is the operation that used to strip them).🤖 Generated with Claude Code