llama-cli -hf Cache Path: Find and Change the GGUF Download Folder

Explains the Hugging Face Hub cache used by llama-cli -hf, environment-variable precedence, path inspection, and safe cache migration.

When you run a Hugging Face model directly with llama-cli, for example:

1
llama-cli -hf unsloth/gemma-4-E4B-it-GGUF

the download is handled by llama.cpp. Current releases place -hf downloads in the standard Hugging Face Hub cache.

Default cache locations

For the current Hub download path, HF_HUB_CACHE has priority. If it is unset, the path is $HF_HOME/hub; otherwise it is derived from XDG_CACHE_HOME, and finally from the user’s default cache directory. LLAMA_CACHE, often mentioned in older guides, is a llama.cpp-specific or legacy setting and should not be presented as the highest-priority variable for the current standard -hf Hub cache.

System Default cache directory
Linux ~/.cache/huggingface/hub
macOS ~/.cache/huggingface/hub
Windows %USERPROFILE%\.cache\huggingface\hub

On Windows, %USERPROFILE% normally points to:

1
C:\Users\your-name

so the default cache is approximately:

1
C:\Users\your-name\.cache\huggingface\hub

Check the path the process will actually use

Linux and macOS:

1
2
3
4
env | grep -E '^(HF_HOME|HF_HUB_CACHE|XDG_CACHE_HOME|LLAMA_CACHE)='
HUB_CACHE="${HF_HUB_CACHE:-${HF_HOME:-${XDG_CACHE_HOME:-$HOME/.cache}/huggingface}/hub}"
printf '%s\n' "$HUB_CACHE"
find "$HUB_CACHE" -type f -name '*.gguf' -printf '%p\t%s bytes\n'

Windows PowerShell:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Get-ChildItem Env:HF_HOME,Env:HF_HUB_CACHE,Env:XDG_CACHE_HOME,Env:LLAMA_CACHE -ErrorAction SilentlyContinue

$hub = if ($env:HF_HUB_CACHE) {
    $env:HF_HUB_CACHE
} elseif ($env:HF_HOME) {
    Join-Path $env:HF_HOME 'hub'
} elseif ($env:XDG_CACHE_HOME) {
    Join-Path $env:XDG_CACHE_HOME 'huggingface\hub'
} else {
    Join-Path $env:USERPROFILE '.cache\huggingface\hub'
}

$hub
Get-ChildItem -LiteralPath $hub -Recurse -Filter *.gguf -ErrorAction SilentlyContinue

Variables set by systemd, a container, or an IDE may not appear in your current terminal. Check the service, Compose file, or launch script as well, and confirm the path from the actual llama-cli download log and files on disk.

Change the cache directory

Use HF_HUB_CACHE when you only want to move Hub model files. Use HF_HOME when you want to move Hugging Face tokens, assets, and the Hub cache together.

Windows Command Prompt:

1
2
set HF_HUB_CACHE=D:\models\huggingface-hub
llama-cli -hf unsloth/gemma-4-E4B-it-GGUF

Windows PowerShell:

1
2
$env:HF_HUB_CACHE="D:\models\huggingface-hub"
llama-cli -hf unsloth/gemma-4-E4B-it-GGUF
1
2
export HF_HUB_CACHE=/data/models/huggingface-hub
llama-cli -hf unsloth/gemma-4-E4B-it-GGUF

Migrate the cache safely

Stop every downloader, llama-cli process, and service using the cache. Copy first, verify, switch the variable, and only then deal with the old directory:

1
2
3
4
5
6
old="$HOME/.cache/huggingface/hub"
new="/data/models/huggingface-hub"
mkdir -p "$new"
rsync -aH --info=progress2 "$old/" "$new/"
du -sb "$old" "$new"
HF_HUB_CACHE="$new" llama-cli -hf unsloth/gemma-4-E4B-it-GGUF -n 1

After the byte totals are close and a minimal inference succeeds from the new path, persist HF_HUB_CACHE in the shell, service, or container configuration. Keep the old directory until another normal startup succeeds. For shared caches, restrict write access so another user cannot replace model files.

Summary

  • Current llama-cli -hf downloads use the standard Hugging Face Hub cache.
  • Linux/macOS default: ~/.cache/huggingface/hub.
  • Windows default: %USERPROFILE%\.cache\huggingface\hub.
  • Use HF_HUB_CACHE for the model cache or HF_HOME for all Hugging Face data.
  • Migrate by stopping, copying, checking, switching, testing, and only then archiving the old directory.

References: