guide
Delete old Python .venv and Rust target folders safely
Quick answer
Python: a folder is a virtual environment if it contains pyvenv.cfg; delete it with rm -rf .venv and recreate it with uv sync, poetry install, or python3 -m venv .venv && .venv/bin/pip install -r requirements.txt. Rust: cargo clean in the project deletes target/; cargo build brings it back.
Python: find real virtual environments
Names like env or venv aren't proof. A virtual environment always has a pyvenv.cfg file at its top:
find ~/Projects -name node_modules -prune -o -name pyvenv.cfg -print
Each result's folder is a venv (skipping node_modules keeps the search fast). Delete it with rm -rf; nothing inside is your code.
Recreate it
| The project has | Command |
|---|---|
uv.lock | uv sync |
poetry.lock | poetry install |
Pipfile | pipenv install |
requirements.txt | python3 -m venv .venv && .venv/bin/pip install -r requirements.txt |
pyproject.toml only | python3 -m venv .venv && .venv/bin/pip install -e . |
Rust: target folders
Cargo's target/ holds every build profile and dependency you compiled, and grows with each toolchain update. In the project folder:
cargo clean
It's only a Rust build folder if there's a Cargo.toml next to it (Cargo also writes a CACHEDIR.TAG file inside). A target folder next to a pom.xml is Maven's build output instead: mvn clean or ./mvnw clean.
The shared caches
- pip:
pip cache purge(pip cache dirshows where it is). - uv:
uv cache pruneremoves only unused entries;uv cache cleanempties it. - Cargo: downloaded crates live in
~/.cargo/registryand are shared by every Rust project.
Questions
Is it safe to delete .venv?
Yes. It only holds the Python interpreter link and installed packages. Recreate it from your lockfile or requirements.txt.
How do I know a folder named env is a virtual environment?
It has a pyvenv.cfg file at its top. Without that file, it is probably something else, like configuration.
What does cargo clean delete?
The project's target directory, where Cargo keeps compiled output. cargo build recreates what it needs.
Is ~/.cargo/registry safe to delete?
It is a download cache of crates shared by all projects; Cargo downloads them again when needed.