uv sync
deletes data in non-virtualenv UV_PROJECT_ENVIRONMENT
without warning
#7519
Labels
bug
Something isn't working
Environment
Background
I have a directory
projects
containing multiple related Git repos (bar
,baz
, etc) with Python projects that all need to be installed into the same virtualenv because they are a core and a set of extensions.At https://docs.astral.sh/uv/configuration/environment/ I read about
UV_PROJECT_ENVIRONMENT
:At this point, it was a bit unclear to me if this variable was:
.venv
directory.I learned the hard way that 1 is the right interpretation, but I went with 2 without testing my assumptions.
The mishap
So, given this setup:
I assumed that
UV_PROJECT_ENVIRONMENT
was supposed to point to the directory containing the.venv
, without testing my assumption, and did the following:At this point, the
projects
directory is a virtualenv. Thebar
andbaz
projects are gone, as well as thevaluable-data.txt
file.I realize that this was my fault for not testing assumptions, and no data not tracked in Git was lost. However, the behavior was surprising.
Suggestions
Documentation
Make the documentation for
UV_PROJECT_ENVIRONMENT
even more explicit about it pointing to the virtualenv directory itself.Behavior
Only let
uv sync
create/recreate a virtualenv if the path pointed to byUV_PROJECT_ENVIRONMENT
eitherIn any other case, abort with a message explaining the problem.
The text was updated successfully, but these errors were encountered: