Mounting datasets cache fails due to absolute paths.
CONTRIBUTOR
You may be able to make it work by tweaking some environment variables, such as [`HF_HOME`](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/environment_variables#hfhome) or [`HF_DATASETS_CACHE`](https://huggingface.co/docs/datasets/cache#cache-directory).
2023-10-27T15:04:16Z
https://github.com/huggingface/datasets/issues/6358#issuecomment-1783071235
https://api.github.com/repos/huggingface/datasets/issues/6358
IC_kwDODunzps5qR4ID
https://api.github.com/repos/huggingface/datasets/issues/comments/1783071235/reactions
2023-10-27T15:04:16Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1783071235
https://avatars.githubusercontent.com/u/21087104?v=4
https://api.github.com/users/Laurent2916/events{/privacy}
https://api.github.com/users/Laurent2916/followers
https://api.github.com/users/Laurent2916/following{/other_user}
https://api.github.com/users/Laurent2916/gists{/gist_id}
https://github.com/Laurent2916
Laurent2916
MDQ6VXNlcjIxMDg3MTA0
https://api.github.com/users/Laurent2916/orgs
https://api.github.com/users/Laurent2916/received_events
https://api.github.com/users/Laurent2916/repos
https://api.github.com/users/Laurent2916/starred{/owner}{/repo}
https://api.github.com/users/Laurent2916/subscriptions
User
https://api.github.com/users/Laurent2916
public
NONE
> You may be able to make it work by tweaking some environment variables, such as [`HF_HOME`](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/environment_variables#hfhome) or [`HF_DATASETS_CACHE`](https://huggingface.co/docs/datasets/cache#cache-directory).

I am already doing this. The problem is that, while this seemingly allows flexibility, the absolute paths written into the cache still have the old cache directory. The paths written into the cache should be relative to the cache location to allow this sort of flexibility. Sorry, I omitted this in the reproduction steps, I have now added it.
2023-10-30T09:31:39Z
https://github.com/huggingface/datasets/issues/6358#issuecomment-1784804628
https://api.github.com/repos/huggingface/datasets/issues/6358
IC_kwDODunzps5qYfUU
https://api.github.com/repos/huggingface/datasets/issues/comments/1784804628/reactions
2023-10-30T09:33:15Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1784804628
https://avatars.githubusercontent.com/u/72921588?v=4
https://api.github.com/users/charliebudd/events{/privacy}
https://api.github.com/users/charliebudd/followers
https://api.github.com/users/charliebudd/following{/other_user}
https://api.github.com/users/charliebudd/gists{/gist_id}
https://github.com/charliebudd
charliebudd
MDQ6VXNlcjcyOTIxNTg4
https://api.github.com/users/charliebudd/orgs
https://api.github.com/users/charliebudd/received_events
https://api.github.com/users/charliebudd/repos
https://api.github.com/users/charliebudd/starred{/owner}{/repo}
https://api.github.com/users/charliebudd/subscriptions
User
https://api.github.com/users/charliebudd
public
COLLABORATOR
I'm unable to reproduce this with the cache
```bash
export HF_CACHE=$PWD/hf_cache
python -c "import datasets; datasets.load_dataset('imdb')"
```
imported inside a dummy container that is built from
```bash
FROM python:3.9

WORKDIR /usr/src/app

RUN pip install datasets

COPY ./hf_cache ./hf_cache

ENV HF_HOME=./hf_cache
ENV HF_DATASETS_OFFLINE=1

CMD ["python"]
```
What do you mean by "absolute paths written into the cache"? Paths inside the HF cache paths are based on hash (hashed URL of the downloaded files, etc.)
2023-11-03T14:20:02Z
https://github.com/huggingface/datasets/issues/6358#issuecomment-1792523127
https://api.github.com/repos/huggingface/datasets/issues/6358
IC_kwDODunzps5q17t3
https://api.github.com/repos/huggingface/datasets/issues/comments/1792523127/reactions
2023-11-03T14:20:02Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1792523127
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
NONE
@mariosasko Same problem:  the absolute paths written into the cache still have the old cache directory. Like:

{'bytes': None, 'path': 'E:\\work-20240321\\datasets\\downloads\\extracted\\9752883596854dc57e01c74cc3f494b2ba63754dadd9e77f9d1932deddbd2273\\58f33a03-026f-4adc-b69f-b89d16b9f35a.webp'}

When I move this cached directory to another directory, these datasets cannot be used casue path changes. So, the paths written into the cache should be relative to the cache location to allow this sort of flexibility. 
2024-04-09T15:47:31Z
https://github.com/huggingface/datasets/issues/6358#issuecomment-2045526581
https://api.github.com/repos/huggingface/datasets/issues/6358
IC_kwDODunzps557EI1
https://api.github.com/repos/huggingface/datasets/issues/comments/2045526581/reactions
2024-04-09T15:47:31Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2045526581
https://avatars.githubusercontent.com/u/43101596?v=4
https://api.github.com/users/haoweiz23/events{/privacy}
https://api.github.com/users/haoweiz23/followers
https://api.github.com/users/haoweiz23/following{/other_user}
https://api.github.com/users/haoweiz23/gists{/gist_id}
https://github.com/haoweiz23
haoweiz23
MDQ6VXNlcjQzMTAxNTk2
https://api.github.com/users/haoweiz23/orgs
https://api.github.com/users/haoweiz23/received_events
https://api.github.com/users/haoweiz23/repos
https://api.github.com/users/haoweiz23/starred{/owner}{/repo}
https://api.github.com/users/haoweiz23/subscriptions
User
https://api.github.com/users/haoweiz23
public
NONE
Sorry, the reply on this thread escaped my attention. The problem with @mariosasko's attempted reproduction is the absolute path `./hf_cache`  is the same in the host system and the docker container, so naturally the paths would be correct. Modifying the docker image as below should reproduce the error...

```
FROM python:3.9

WORKDIR /usr/src/app

RUN pip install datasets

COPY ./hf_cache ./my_cache/

ENV HF_HOME=./my_cache/
ENV HF_DATASETS_OFFLINE=1

CMD ["python"]
```

The paths written inside the cache will still have `./hf_cache` prefixing all the paths. If they were relative paths (relative to the top level of the cache) this would be avoided.
2024-04-10T08:47:54Z
https://github.com/huggingface/datasets/issues/6358#issuecomment-2046932873
https://api.github.com/repos/huggingface/datasets/issues/6358
IC_kwDODunzps56AbeJ
https://api.github.com/repos/huggingface/datasets/issues/comments/2046932873/reactions
2024-04-10T08:50:06Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2046932873
https://avatars.githubusercontent.com/u/72921588?v=4
https://api.github.com/users/charliebudd/events{/privacy}
https://api.github.com/users/charliebudd/followers
https://api.github.com/users/charliebudd/following{/other_user}
https://api.github.com/users/charliebudd/gists{/gist_id}
https://github.com/charliebudd
charliebudd
MDQ6VXNlcjcyOTIxNTg4
https://api.github.com/users/charliebudd/orgs
https://api.github.com/users/charliebudd/received_events
https://api.github.com/users/charliebudd/repos
https://api.github.com/users/charliebudd/starred{/owner}{/repo}
https://api.github.com/users/charliebudd/subscriptions
User
https://api.github.com/users/charliebudd
public
### Describe the bug

Creating a datasets cache and mounting this into, for example, a docker container, renders the data unreadable due to absolute paths written into the cache.

### Steps to reproduce the bug

1. Create a datasets cache by downloading some data
2. Mount the dataset folder into a docker container or remote system.
3. (Edit) Set `HF_HOME` or `HF_DATASET_CACHE` to point to the mounted cache.
4. Attempt to access the data from within the docker container.
5. An error is thrown saying no file exists at \<absolute path to original cache location\>

### Expected behavior

The data is loaded without error

### Environment info

- `datasets` version: 2.14.4
- Platform: Linux-5.4.0-162-generic-x86_64-with-glibc2.29
- Python version: 3.8.10
- Huggingface_hub version: 0.16.4
- PyArrow version: 13.0.0
- Pandas version: 2.0.3