Make the cache dir wherever uv is called from when --no-cache specified #11477
+12
−9
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
As brought up here, using the tempfile::env::temp_dir default per system is not ideal for cases where directories are on different mounts, or simply in the context where the system user doesn't have write permissions the temp_dir default.
I read the initial issue and @charliermarsh 's follow up comment and I think the coupling to the virtual env directory is not necessary, and instead I think we can simply default the tempdir to the directory where uv is being invoked from. I think this is a sensible default since it is common to run the project from the project root AND the .venv directory is created in the project root so we should have write permissions here.
In case for some reason the directory that uv is invoked from also doesn't have write permissions (or you just don't want the temp cache there for some reason?), I added a commit that will respect UV_CACHE_DIR so that these users can provide a directory for a temp cache when using --no-cache
Test Plan
Also used the uv build for building/syncing some test projects and it seems to work fine, I think the test suite for uv will be more comprehensive, however.