Skip to content

weird behaviour of uv sync and the uv cache #16786

@kforner

Description

@kforner

Summary

When I preinstall a package using uv pip install, the cache seems to be populated but uv sync does not use it.
Here's a Dockerfile:

FROM ubuntu:24.04
COPY --from=ghcr.io/astral-sh/uv:0.9.8 /uv /uvx /bin/
USER ubuntu
RUN uv python install 3.14
WORKDIR /home/ubuntu

RUN uv venv && uv pip install pandas && rm -rf .venv
COPY --chown=ubuntu:ubuntu py_dev/project_only/pyproject.toml .

RUN ls  -ls ~/.cache/uv/wheels-v5/pypi/

RUN rm  -rf .venv && uv sync --link-mode copy -v 2>&1 | grep pandas | grep  Identified
RUN rm  -rf .venv && uv sync --link-mode copy -v 2>&1 | grep pandas 

Here's the pyproject.toml:

[project]
name = "dummy"
version = "0.1.0"
requires-python = ">=3.14"
dependencies = [ 
    "pandas"
]

and here's the interesting part of the docker build output:

#16 [stage-0 10/12] RUN ls  -ls ~/.cache/uv/wheels-v5/pypi/
#16 0.157 total 24
#16 0.157 4 drwxr-xr-x 2 ubuntu ubuntu 4096 Nov 20 10:28 numpy
#16 0.157 4 drwxr-xr-x 2 ubuntu ubuntu 4096 Nov 20 10:28 pandas
#16 0.157 4 drwxr-xr-x 2 ubuntu ubuntu 4096 Nov 20 10:28 python-dateutil
#16 0.157 4 drwxr-xr-x 2 ubuntu ubuntu 4096 Nov 20 10:28 pytz
#16 0.157 4 drwxr-xr-x 2 ubuntu ubuntu 4096 Nov 20 10:28 six
#16 0.157 4 drwxr-xr-x 2 ubuntu ubuntu 4096 Nov 20 10:28 tzdata
#16 DONE 0.2s

#17 [stage-0 11/12] RUN rm  -rf .venv && uv sync --link-mode copy -v 2>&1 | grep pandas | grep  Identified
#17 18.57 DEBUG Identified uncached distribution: pandas==2.3.3
#17 DONE 18.8s

#18 [stage-0 12/12] RUN rm  -rf .venv && uv sync --link-mode copy -v 2>&1 | grep pandas
#18 0.416 DEBUG Registry requirement already cached: pandas==2.3.3
#18 0.416  + pandas==2.3.3
#18 DONE 0.6s
  • the first uv sync execution states that DEBUG Identified uncached distribution: pandas==2.3.3
  • the second run: DEBUG Registry requirement already cached: pandas==2.3.3
    Since pandas was already installed using uv pip install, and the cache populated, I can't understand what's happening.

Platform

docker on linux

Version

uv 0.9.8

Python version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions