unslothai/unsloth · error · ValueError

The parent folder does not exist.

Error message

The parent folder does not exist.

What it means

Raised when the parent of the resolved cache folder either does not exist or is not a directory (parent.exists() and parent.is_dir() must both hold). The check runs before mkdir because Path.mkdir only creates the final component; a missing grandparent would otherwise produce a raw FileNotFoundError instead of this friendly message.

Source

Thrown at studio/backend/utils/hf_cache_settings.py:272

    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


def _stored_history() -> list[Path]:
    try:
        from storage.studio_db import get_app_setting

View on GitHub (pinned to 203007d190)

Solutions

  1. Create the parent chain first: mkdir -p /mnt/data/hf-cache, then save the setting
  2. If on a removable/network volume, remount it and confirm with 'ls' that the parent is visible
  3. Fix typos in intermediate path components by re-selecting the folder in the picker

Example fix

# before
set_hf_cache_home('/mnt/usb-not-mounted/hf')  # ValueError: parent does not exist

# after (mount the drive first, then)
mkdir -p /mnt/usb/hf
set_hf_cache_home('/mnt/usb/hf')              # ok
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

def parent_ready(raw: str) -> bool:
    parent = Path(raw).expanduser().resolve(strict=False).parent
    return parent.exists() and parent.is_dir()

Prevention

When it happens

Trigger: set_hf_cache_home('/mnt/missing-volume/hf') where /mnt/missing-volume does not exist, or a path whose parent is actually a file (e.g. someone created a file named 'hf-cache' and you pass '/data/hf-cache/inner'). Also when a USB/network mount is unmounted so the parent path no longer resolves.

Common situations: Removable drives that are unplugged between browse and save; network shares not yet mounted at login; typos in intermediate directory names; containers where the volume is mounted at a different path than on the host.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/d9765f5b6cf67449. Report an issue: GitHub.