Skip to main content

How to Change Where Hugging Face Stores Downloaded Models with HF_HOME

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

By default, Hugging Face keeps downloaded models in ~/.cache/huggingface, on your main drive. Models can take many gigabytes, so you may want them on a bigger drive or inside a project. The HF_HOME environment variable moves that whole folder. This guide sets it in bash and PowerShell with huggingface_hub 2.5.0 and checks the result.

Syntax​

Syntax
export HF_HOME="<folder>"
PartWhat it means
HF_HOMEThe folder where Hugging Face libraries keep their data: the cache of downloads and your token
<folder>Where you want it. It's created when first needed

The environment variable reference describes it: "To configure where huggingface_hub will locally store data. In particular, your token and the cache will be stored in this folder." It "Defaults to "~/.cache/huggingface"".

Downloads then go to <folder>/hub, because HF_HUB_CACHE "Defaults to "$HF_HOME/hub"". All Hugging Face libraries, such as Transformers and datasets, read the same variable.

The Example​

A project sets HF_HOME to a folder named hf-cache inside itself, downloads a file, and checks where it went.

Prerequisites​

  • uv. This guide uses uv 0.13.10 with Python 3.15.2.

Step 1: Create a Project with the hf Command​

Terminal
uv init --python 3.15 custom-cache
cd custom-cache
uv add huggingface_hub

Step 2: Set HF_HOME and Download a File​

The command differs between shells:

Terminal
export HF_HOME="$PWD/hf-cache"
uv run hf download google-bert/bert-base-uncased config.json

$PWD is the folder you're in, so the cache goes to hf-cache inside the project.

Output
Hint: The `hf-cli` skill is not installed. Run `hf skills add -g` to teach your AI agents how to use the `hf` CLI.
Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.
config.json: 100%|█████████████████████████████████████████████████| 570/570 [00:00<00:00, 3.80MB/s]
✓ Downloaded
path: /Users/you/source/custom-cache/hf-cache/hub/models--google-bert--bert-base-uncased/snapshots/86b5e0934494bd15c9632b12f734a8a67f723594/config.json

The terminal after setting HF_HOME and running hf download: a hint about the hf-cli skill, the unauthenticated-requests warning, the download, and the path /Users/you/source/custom-cache/hf-cache/hub/models--google-bert--bert-base-uncased/snapshots/86b5e09…/config.json.

The path now starts with /Users/you/source/custom-cache/hf-cache/hub, not ~/.cache/huggingface/hub. The PowerShell version saved the file to the same place.

Two notices came with it. The hint is from the hf command itself: the reference says it checks "at most once every 24 hours, purely locally" whether its skill for AI coding assistants is installed. It keeps the time of its last check in a file inside HF_HOME, .check_for_skill_update_done, so a brand-new HF_HOME shows the hint once. You can ignore it. The warning comes from the Hub and means you're downloading without an account.

Step 3: Check the Setting with hf env​

hf env prints the settings huggingface_hub is using. Run it in the same terminal:

Terminal
uv run hf env
Output
Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 2.5.0
- Platform: macOS-26.7.4-arm64-arm-64bit-Mach-O
- Python version: 3.15.2
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Running in Google Colab Enterprise ?: No
- Token path ?: /Users/you/source/custom-cache/hf-cache/token
- Has saved token ?: False
- Configured git credential helpers: osxkeychain
- Run by AI agent ?: No
- Installation method: unknown
- httpx2: 2.17.0
- hf_xet: 1.8.0
- gradio: N/A
- tensorboard: N/A
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: /Users/you/source/custom-cache/hf-cache/hub
- HF_ASSETS_CACHE: /Users/you/source/custom-cache/hf-cache/assets
- HF_TOKEN_PATH: /Users/you/source/custom-cache/hf-cache/token
- HF_STORED_TOKENS_PATH: /Users/you/source/custom-cache/hf-cache/stored_tokens
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS: False
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_DISABLE_XET: False
- HF_HUB_DISABLE_SHARED_BLOBS: False
- HF_HUB_ETAG_TIMEOUT: 10
- HF_HUB_DOWNLOAD_TIMEOUT: 10
- HF_XET_HIGH_PERFORMANCE: False

The terminal after uv run hf env: the huggingface_hub version, platform and Python, then the paths HF_HUB_CACHE, HF_ASSETS_CACHE, HF_TOKEN_PATH and HF_STORED_TOKENS_PATH, all inside /Users/you/source/custom-cache/hf-cache, and the other settings.

Every path, the cache, the assets and the token, now sits inside hf-cache, which is what "your token and the cache will be stored in this folder" means.

Keep the Setting for Every Terminal​

export and $env: last only for the terminal you type them in. A new terminal goes back to ~/.cache/huggingface. To make the setting permanent, add the same line to your shell's startup file, such as ~/.zshrc on macOS, or set HF_HOME as a user environment variable in Windows' settings. Use a fixed folder for that, not $PWD, which changes with the folder you're in.

Common Mistakes​

MistakeWhat happensDo this instead
Setting HF_HOME in one terminal and running the program in anotherThe program still uses ~/.cache/huggingfaceSet it in the terminal that runs the program, or permanently
Changing HF_HOME after a Python program has startedThe library has already read itSet it before the program starts
Expecting the old cache to move by itselfModels already downloaded stay where they were, and are downloaded again into the new folderMove the old folder yourself, or delete it with hf cache rm

FAQ​

What's the difference between HF_HOME and HF_HUB_CACHE?​

HF_HOME moves everything, including your token. HF_HUB_CACHE moves only the downloads and leaves the token where it is.

Does Transformers use this setting too?​

Yes. The Transformers installation guide lists HF_HOME among the variables that choose the cache folder.

Conclusion​

With HF_HOME set to hf-cache inside the project, hf download saved the file to hf-cache/hub, and hf env showed the cache and token paths inside it too.

Additional Resources​