Skip to content

failed to write to site-packages when using uv, works fine with vanilla pip #3635

Description

@jamiekt

I'm trying to use uv in a docker image build. As uv is meant to be a "drop-in replacement" I've pretty much done that, dropped it in, and its failing with a permissions error.

here is my Dockerfile, I'm aware of the new --system flag (#2046) so I'm using that.

ARG AIRFLOW_VERSION="2.4.1"
FROM apache/airflow:slim-${AIRFLOW_VERSION}-python3.10 as base
FROM base as development
USER root
RUN apt update && apt install -y unzip libsasl2-dev build-essential && \
    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
    unzip awscliv2.zip && \
    ./aws/install && \
    rm -rf awscliv2.zip ./aws/
USER airflow
COPY requirements-dev.txt requirements-dev.txt
RUN pip install uv && uv pip install --no-cache-dir --system -r requirements-dev.txt

requirements_dev.txt is simply this:

aiofiles==23.2.1

(my actual requirements file is far more complicated than this, but this is sufficient to repro the error)

The build (docker build --target development .) fails with

24.74 Caused by: failed to create directory /usr/local/lib/python3.10/site-packages/aiofiles-23.2.1.dist-info
24.74 Caused by: Permission denied (os error 13)

If I do not use uv:

ARG AIRFLOW_VERSION="2.4.1"
FROM apache/airflow:slim-${AIRFLOW_VERSION}-python3.10 as base
FROM base as development
USER root
RUN apt update && apt install -y unzip libsasl2-dev build-essential && \
    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
    unzip awscliv2.zip && \
    ./aws/install && \
    rm -rf awscliv2.zip ./aws/
USER airflow
COPY requirements-dev.txt requirements-dev.txt
RUN pip install --no-cache-dir --user -r requirements-dev.txt

then it works fine.

As uv is badged as a "drop-in replacement" is it fair to expect this to work? Any guidance on the best way to fix this would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions