Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the cache dir wherever uv is called from when --no-cache specified #11477

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shaneikennedy
Copy link
Contributor

@shaneikennedy shaneikennedy commented Feb 13, 2025

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

uv git:main*
❯ UV_CACHE_DIR="/Users/shane.kennedy/dev/shane/" target/debug/uv cache dir --no-cache
/Users/shane.kennedy/dev/shane/.tmpfBmOPp

uv git:main*
❯ target/debug/uv cache dir --no-cache
/Users/shane.kennedy/dev/shane/uv/.tmp4b6zap

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.

@shaneikennedy shaneikennedy force-pushed the main branch 3 times, most recently from 80fd6c1 to d62fb00 Compare February 13, 2025 13:30
@shaneikennedy shaneikennedy marked this pull request as ready for review February 13, 2025 13:42
@shaneikennedy shaneikennedy changed the title Make the cache dir inside project when --no-cache specified Make the cache dir wherever uv is called from when --no-cache specified Feb 13, 2025
@shaneikennedy
Copy link
Contributor Author

shaneikennedy commented Feb 17, 2025

@edmorley Hey :) Since this PR attempts to cover your use-case in the issue you submitted re:--no-cache, would you mind taking a look at the PR description and letting me know if you think this would resolve the issue for you at Heroku, please? I think I understood your problem correctly but want to double check

I know your suggestion was to put the temp dir inside the venv but I understood that the main problem was hard linking and not wanting to do manual cleanup, which should be satisfiable here either by the default (temp dir inside directory where uv is invoked from) or by using UV_CACHE to create the temp dir somewhere that works for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant