unslothai/unsloth · error · ValueError
Credential or config folders cannot be used for model downlo
Error message
Credential or config folders cannot be used for model downloads.
What it means
Raised when contains_sensitive_path_component() from hub.storage.scan_folders finds the resolved cache path overlaps credential/config locations such as ~/.ssh, ~/.gnupg, ~/.aws, or ~/.config. The guard exists because cache folders are often browsed, synced, or moved by the UI, and putting gigabytes of model files next to credentials risks leaking or overwriting them (the code even notes HF_HOME also controls the token path, so credentials must not move onto a cache volume).
Source
Thrown at studio/backend/utils/hf_cache_settings.py:268
resolved = candidate.resolve(strict = False)
except (OSError, RuntimeError, ValueError) as exc:
raise ValueError("The Hugging Face cache folder is invalid.") from exc
if resolved.parent == resolved:
raise ValueError("Choose a folder inside the filesystem or drive root.")
try:
from hub.storage.scan_folders import (
contains_sensitive_path_component,
is_denied_system_path,
)
except ImportError:
contains_sensitive_path_component = is_denied_system_path = None
if is_denied_system_path is not None and is_denied_system_path(str(resolved)):
raise ValueError("System folders cannot be used for model downloads.")
if contains_sensitive_path_component is not None and contains_sensitive_path_component(
str(resolved)
):
raise ValueError("Credential or config folders cannot be used for model downloads.")
parent = resolved.parent
if not parent.exists() or not parent.is_dir():
raise ValueError("The parent folder does not exist.")
try:
resolved.mkdir(exist_ok = True)
if not resolved.is_dir():
raise ValueError("The selected cache location is not a folder.")
for child in (resolved / "hub", resolved / "xet"):
child.mkdir(exist_ok = True)
with tempfile.NamedTemporaryFile(prefix = ".unsloth-write-test-", dir = child):
pass
except PermissionError as exc:
raise ValueError("Studio does not have permission to write to this folder.") from exc
except OSError as exc:
raise ValueError(f"Studio cannot use this cache folder: {exc}") from exc
return resolved
View on GitHub (pinned to 203007d190)
Solutions
- Move the cache to a dedicated non-dot directory, e.g. ~/hf-cache or ~/Library/Caches/huggingface on macOS
- Review hub.storage.scan_folders contains_sensitive_path_component to see the exact component list if unsure why a path matched
- Keep credentials and model caches on entirely separate directory trees
Example fix
# before
set_hf_cache_home('~/.config/hf-cache') # ValueError: credential/config folders
# after
set_hf_cache_home('~/hf-cache') # ok Defensive patterns
Strategy: validation
Validate before calling
from hub.storage.scan_folders import contains_sensitive_path_component
def sensitive_choice(raw: str) -> bool:
return contains_sensitive_path_component(str(Path(raw).expanduser().resolve(strict=False))) Prevention
- Never colocate model caches with ~/.ssh, ~/.aws, ~/.gnupg, or ~/.config contents
- Remember the check matches path components anywhere, not just the leaf
When it happens
Trigger: set_hf_cache_home('~/.ssh/hf'), '~/.config/huggingface', or any path containing a sensitive component anywhere in it (the helper checks components, so '/home/me/.aws/cache' also matches). Requires the scan_folders import to have succeeded and the earlier system-path check to have passed.
Common situations: Users assume '~/.config/huggingface' is the natural spot because other tools keep config there; or they reuse a dotfolder that happens to be on the sensitive list. CI setups that stash everything under ~/.config also hit it.
Related errors
- System folders cannot be used for model downloads.
- {_cn_fs.reason}
- Non-GGUF video loads are limited to unsloth/* repos, the off
- The Hugging Face cache folder is invalid.
- Choose a folder inside the filesystem or drive root.
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/010f9c536e9b8119.
Report an issue: GitHub.