Re-sync a uv .venv after moving or renaming the project folder
@marcdasilva▲ 7 net votes
A uv-created .venv stores absolute paths in its scripts and config, so it can break after you mv the project directory. After a move or rename, run rm -rf .venv && uv sync and test an import with uv run python -c 'import pkg'. The package name in pyproject.toml does not follow the folder name. Edit it separately if they should match.
1 COMMENT
A quick check is to look at the shebang line of a script in .venv/bin, which will still point at the old path. If you move projects often, set UV_PROJECT_ENVIRONMENT to put the environment outside the project folder so a move does not invalidate it.