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

Document strategies for sharing the cache #5611

Open
zanieb opened this issue Jul 30, 2024 · 5 comments
Open

Document strategies for sharing the cache #5611

zanieb opened this issue Jul 30, 2024 · 5 comments
Labels
cache Caching of packages and metadata documentation Improvements or additions to documentation

Comments

@zanieb
Copy link
Member

zanieb commented Jul 30, 2024

Per #5581 (comment), sharing the cache across users can be useful for system-wide uv installations.

@zanieb zanieb added documentation Improvements or additions to documentation cache Caching of packages and metadata labels Jul 30, 2024
@stas00
Copy link

stas00 commented Jul 31, 2024

Here is the summary so far of what needs to be done to make uv work with a shared cache - this helps to save a ton of disk space and inodes when there are many users on a system and files can be shared.

  1. add to ~/.bashrc or ~/.profile of each user:
umask 000 # file creation so that all users's files are a+rw or a+rwx
export UV_LINK_MODE=copy # hardlinking doesn't work with different owners
  1. Then create a shared cache folder:
sudo mkdir -p /data/cache/uv
sudo chmod a+rwx /data/cache/uv
  1. Then each user redirecting their local cache to the shared one:
rm -r ~/.cache/uv
ln -s /data/cache/uv ~/.cache/uv

and this requires uv>=0.2.32 to work

Done.

@zanieb
Copy link
Member Author

zanieb commented Jul 31, 2024

Thanks! If you're setting environment variables anyway, you can use UV_CACHE_DIR and skip the symbolic link.

@stas00
Copy link

stas00 commented Jul 31, 2024

oh, that's super-useful, then I don't have to go after users and making sure they installed a symlink.

Thank you very much, @zanieb!

@paveldikov
Copy link
Contributor

Worth mentioning (or even discussing!) the security implications of this. (cache poisoning can be a huge problem)

@MattiasDC
Copy link

If you can't or don't want to use umask (as it will change behavior it for all files you create, not only uv cache). You can also use ACL rules on the cache directory, which overrides umask configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cache Caching of packages and metadata documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants