# Huggingface Embeddings Cache folder error when trying to deploy fastAPI app in Huggingface Spaces

**URL:** <https://discuss.huggingface.co/t/huggingface-embeddings-cache-folder-error-when-trying-to-deploy-fastapi-app-in-huggingface-spaces/64370>\
**Category:** Spaces\
**Created:** [December 2, 2023, 7:48pm UTC](https://discuss.huggingface.co/t/huggingface-embeddings-cache-folder-error-when-trying-to-deploy-fastapi-app-in-huggingface-spaces/64370 "2023-12-02T19:48:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HemanthSai7](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/hemanthsai7/32/39341_2.png) [@HemanthSai7](https://discuss.huggingface.co/u/HemanthSai7)\
**Post date:** [December 2, 2023, 7:48pm UTC](https://discuss.huggingface.co/t/huggingface-embeddings-cache-folder-error-when-trying-to-deploy-fastapi-app-in-huggingface-spaces/64370/1 "2023-12-02T19:48:20Z")

</div>

I’m creating a chatbot and have used `BAAI/llm-embedder` model via `HuggingFaceBgeEmbeddings` class from `langchain`. But I am facing the following issue  
`There was a problem when trying to write in your cache folder (/.cache/huggingface/hub). You should set the environment variable TRANSFORMERS_CACHE to a writable directory.`

As mentioned I have also tried setting the environment variable but still the same error occurs. I have also tried passing the path in parameters in the function.

```python
def store_embeddings(self, docs):
        embeddings = HuggingFaceBgeEmbeddings(
            model_name=self.cfg.EMBEDDINGS,
            model_kwargs={"device": self.cfg.DEVICE},
            encode_kwargs={"normalize_embeddings": self.cfg.NORMALIZE_EMBEDDINGS},
            cache_folder = self.cfg.CACHE_FOLDER
        )

```

My Space: [StudybotAPI - a Hugging Face Space by HemanthSai7](https://huggingface.co/spaces/HemanthSai7/StudybotAPI)

I deployed this fastAPI instance in spaces via docker and the main backend code lies `StudybotAPI/backend`

My dockerfile

```bash
FROM python:3.10.9

COPY ./StudybotAPI .

WORKDIR /

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

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]

```

Need some help in fixing this issue.  
Thank you

---

<div class="post-metadata">

**Author:** ![saicharan1234](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@saicharan1234](https://discuss.huggingface.co/u/saicharan1234)\
**Post date:** [December 13, 2023, 8:21pm UTC](https://discuss.huggingface.co/t/huggingface-embeddings-cache-folder-error-when-trying-to-deploy-fastapi-app-in-huggingface-spaces/64370/2 "2023-12-13T20:21:29Z")

</div>

im having this same issue !! did u find any solution?
