uv warns it failed to hardlink files and copies them instead
Your error
Failed to hardlink files; falling back to full copy. This may lead to degraded performance.2 more lines it can showFix it fast
Most common cause, 1 of 3A BuildKit cache mount keeps the uv cache apart from the image layer
Declare copy mode before the RUN step.
ENV UV_LINK_MODE=copy
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --lockedShort answer
uv prints Failed to hardlink files; falling back to full copy when its cache and the .venv sit on different filesystems. A Docker cache mount, a .venv volume beside a bind-mounted project, or a Windows project on another drive cause it. The install still succeeds. Set UV_LINK_MODE=copy, or move UV_CACHE_DIR beside the project. Applies to uv 0.13.
Which cause do you have?
Ask uv where its cache lives, then compare the mount behind that folder with the mount behind the environment. Two different Mounted on values confirm a filesystem split.
uv cache dir
df "$(uv cache dir)" .venvThen find the line you see in this list and open its fix:
- 1A BuildKit cache mount keeps the uv cache apart from the image layer
The warning appears during docker build, on a RUN line that starts with --mount=type=cache,target=/root/.cache/uv - 2In a dev container, .venv sits on a volume while the cache stays in the container
The warning shows up when uv sync runs inside a running container that was started with --volume .:/app --volume /app/.venv, or a compose file with similar volumes - 3On Windows the project lives on a different drive from the cache
No Docker involved; the project is on D: or a network drive while uv cache dir prints a path under C:\Users\<you>\AppData\Local\uv\cache
What does the error look like?
Failed to hardlink files; falling back to full copy. This may lead to degraded performance.If the cache and target directories are on different filesystems, hardlinking may not be supported.If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Cause 1 of 3
A BuildKit cache mount keeps the uv cache apart from the image layer
You seeThe warning appears during docker build, on a RUN line that starts with --mount=type=cache,target=/root/.cache/uv
Check
During a Docker build, uv shows Failed to hardlink files because the cache mount is a separate filesystem from the layer where uv sync writes .venv. On Linux uv first tries a copy-on-write clone, then a hard link, and both fail across that boundary. uv's Docker guide pins the warning on exactly this split between cache and sync target.
grep -n "mount=type=cache" DockerfileFix
Declare copy mode before the RUN step. Files are copied from the mounted cache, so you keep the download savings and lose only the link speed-up, which this setup cannot use anyway.
ENV UV_LINK_MODE=copy
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --lockedVerify
Rebuild without the layer cache. The uv step ends with its install summary and no hardlink warning.
docker build --no-cache --progress=plain . 2>&1 | grep -i hardlink || echo cleanConfirmed by docs.astral.sh
Cause 2 of 3
In a dev container, .venv sits on a volume while the cache stays in the container
You seeThe warning shows up when uv sync runs inside a running container that was started with --volume .:/app --volume /app/.venv, or a compose file with similar volumes
Check
uv's guide for developing in a container bind-mounts the project and keeps /app/.venv on an anonymous volume. That volume is its own filesystem, while the default cache under /root/.cache/uv belongs to the container's writable layer. Every sync inside the container then has to copy.
docker exec <container> df /root/.cache/uv /app/.venvFix
Pass copy mode into the container with -e, or bake ENV UV_LINK_MODE=copy into the dev image. Pointing UV_CACHE_DIR at a folder on the same volume as the environment is the other option, and it lets links work again.
docker run --rm -e UV_LINK_MODE=copy \
--volume .:/app --volume /app/.venv <image> uv syncVerify
Run uv sync in the container again. It completes without the warning.
docker exec <container> uv syncConfirmed by docs.astral.sh
Cause 3 of 3
On Windows the project lives on a different drive from the cache
You seeNo Docker involved; the project is on D: or a network drive while uv cache dir prints a path under C:\Users\<you>\AppData\Local\uv\cache
Check
uv's settings reference lists hardlink as the default link mode on Windows and %LOCALAPPDATA%\uv\cache as the default cache folder. A project kept on another drive therefore sits on another filesystem, and the hard link attempt falls back to copying.
uv cache dirFix
Move the cache to the project's drive with UV_CACHE_DIR, then let uv rebuild the environment. If the cache must stay on C:, set UV_LINK_MODE to copy instead.
# PowerShell, for the current session
$env:UV_CACHE_DIR = "D:\uv-cache"
uv sync --reinstallVerify
uv cache dir now prints the D: folder and uv sync finishes with no warning.
uv cache dirConfirmed by docs.astral.sh
How do I stop it coming back?
- Put ENV UV_LINK_MODE=copy at the top of every Dockerfile that uses a uv cache mount, next to the uv binary COPY line.
- List .venv in .dockerignore; an environment made on your laptop is tied to its platform and should be rebuilt inside the image.
- On Windows, keep the uv cache on the drive that holds your projects and set UV_CACHE_DIR in the user environment.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: TaxiDex, Dispatch Pro.