astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
20.31k stars 604 forks source link

uv falls back to copy instead of symlink #7509

Open ypnos opened 20 hours ago

ypnos commented 20 hours ago

When using a Docker cache mount, as recommended in the documentation, uv falls back to copying instead of hardlinking and complains about it. The message also recommends to suppress the complaint with explicitely setting the link mode to COPY.

See https://github.com/astral-sh/uv/blob/fe4e39a230c1d48c706a031838e76969b43cd2bf/crates/install-wheel-rs/src/linker.rs#L443

As a matter of fact, uv now supports link mode "symlink".

  1. It would probably be great to try symlink before falling back to copy
  2. The error message makes it sound like we have to live with the performance degradation, and does not mention that symlink mode is also available
  3. The Docker documentation should include ENV UV_LINK_MODE=symlink so that people do not run into this issue. See https://docs.astral.sh/uv/guides/integration/docker/#caching
charliermarsh commented 20 hours ago

Symlinks are fairly problematic, since if the cache gets deleted, your entire project will break. I generally would not want to default to them.

zanieb commented 20 hours ago

We set copy in the example at https://github.com/astral-sh/uv-docker-example/blob/3d2a5afd814babec58804b9ffce923ea114a76fb/Dockerfile#L10-L11 — needs to be updated over here.

notatallshaw commented 18 hours ago

Symlinks are fairly problematic, since if the cache gets deleted, your entire project will break. I generally would not want to default to them.

I use symlink mode at work and I agree with this, I've hit an issue twice where I had to recreate my entire environment, for me it's worth the trade off but I think a user should know they are opting into symlink.