fix(setup): reuse existing uv-created venv instead of failing on rerun - #433
Open
Turkzilla wants to merge 1 commit into
Open
fix(setup): reuse existing uv-created venv instead of failing on rerun#433Turkzilla wants to merge 1 commit into
Turkzilla wants to merge 1 commit into
Conversation
`uv venv` refuses to write into an existing directory unless `--clear`
is passed. The current setup_environment() preserves uv-created venvs
(by skipping the removal block when the `uv_created` marker exists),
then unconditionally calls `uv venv ...` against that same directory.
That call fails on every run after the first with:
error: Failed to create virtual environment
Caused by: A virtual environment already exists at `.pal_venv`.
Use `--clear` to replace it
The script then logs "uv environment creation failed" and falls back
to system Python detection, defeating the uv-first design and
reinstalling all dependencies through pip on every run.
Add a fast-path that detects an existing healthy uv-created venv and
reuses it (echoing the venv's python, matching the function contract).
If the marker is present but the Python is missing or non-executable,
the venv is removed and recreated cleanly.
No behavior change for first-time setup or for non-uv venvs.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates run-server.sh to allow the reuse of existing uv-created virtual environments, which prevents unnecessary recreations and ensures the uv-first design is maintained. A review comment identifies a potential issue where the Python executable path should be double-quoted to safely handle paths containing spaces.
Author
|
Failing Lint |
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.
Summary
uv venvrefuses to write into an existing directory unless--clearis passed. The currentsetup_environment()inrun-server.shpreserves uv-created venvs (by skipping the removal block when theuv_createdmarker exists), then unconditionally callsuv venv ...against that same directory.That call fails on every run after the first with:
The script then logs
uv environment creation failedand falls back to system Python detection, defeating the uv-first design and reinstalling all dependencies through pip on every run.Fix
Add a fast-path that detects an existing healthy uv-created venv and reuses it (echoing the venv's python, matching the function contract).
If the
uv_createdmarker is present but the Python interpreter is missing or non-executable, the venv is removed and recreated cleanly.No behavior change for first-time setup or for non-uv venvs.
Test plan
uv venvcalluv venv --python 3.12.pal_venv/bin/pythonmissing → venv recreated cleanlybash -n run-server.shsyntax check passesRepro of the bug (before this fix)