Permission denied for writing files within Spaces?

I am getting

There was a problem when trying to write in your cache folder (/.cache/huggingface/hub) + some other permission denied messages for writing from my app. Any configuration I missed?

The space in question: H2O Wave Whisper - a Hugging Face Space by h2oai

with a docker file

# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile

FROM python:3.9

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
RUN apt update && apt install -y ffmpeg

COPY . .

ENV H2O_WAVE_LISTEN=":7860"
ENV H2O_WAVE_ADDRESS='http://127.0.0.1:7860'

CMD ["wave", "run", "app", "--no-reload"]

Everything works fine locally. Any help would be highly appreciated!

hi @MartinT ,

I sent you a PR on the hub. You only need to add the write user running the script permission, following this Docker Spaces
changed your Dockerfile to

# you will also find guides on how best to write your Dockerfile

FROM python:3.9

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
RUN apt update && apt install -y ffmpeg

RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
	PATH=/home/user/.local/bin:$PATH

WORKDIR $HOME/app

COPY --chown=user . $HOME/app

ENV H2O_WAVE_LISTEN=":7860"
ENV H2O_WAVE_ADDRESS='http://127.0.0.1:7860'

CMD ["wave", "run", "app", "--no-reload"]
1 Like

Hey bro I am getting this error too

Dockerfile :-

FROM python:3.9

WORKDIR /code

#23
COPY ./requirements.txt /code/requirements.txt

RUN mkdir -p /code && chmod 777 /code

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

COPY . .

CMD ["gunicorn", "-b", "0.0.0.0:7860", "main:app"]

Error :-

PermissionError: [Errno 13] Permission denied: ‘/code/output.log’

can you please try?

FROM python:3.9

RUN useradd -m -u 1000 user
USER user

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt

RUN chown -R user:user /code

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

COPY --chown=user:user . /code

CMD ["gunicorn", "-b", "0.0.0.0:7860", "main:app"]