{"record":{"id":"17409f92bbd6719a","repo":"unslothai/unsloth","slug":"choose-a-folder-inside-the-filesystem-or-drive-roo","errorCode":null,"errorMessage":"Choose a folder inside the filesystem or drive root.","messagePattern":"Choose a folder inside the filesystem or drive root\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/utils/hf_cache_settings.py","lineNumber":255,"sourceCode":"        except OSError:\n            pass\n    return paths\n\n\ndef _validate_cache_home(raw_path: str) -> Path:\n    value = raw_path.strip()\n    if not value:\n        raise ValueError(\"Choose a cache folder.\")\n    candidate = Path(value).expanduser()\n    if not candidate.is_absolute():\n        raise ValueError(\"The Hugging Face cache folder must be an absolute path.\")\n    try:\n        resolved = candidate.resolve(strict = False)\n    except (OSError, RuntimeError, ValueError) as exc:\n        raise ValueError(\"The Hugging Face cache folder is invalid.\") from exc\n\n    if resolved.parent == resolved:\n        raise ValueError(\"Choose a folder inside the filesystem or drive root.\")\n    try:\n        from hub.storage.scan_folders import (\n            contains_sensitive_path_component,\n            is_denied_system_path,\n        )\n    except ImportError:\n        contains_sensitive_path_component = is_denied_system_path = None\n    if is_denied_system_path is not None and is_denied_system_path(str(resolved)):\n        raise ValueError(\"System folders cannot be used for model downloads.\")\n    if contains_sensitive_path_component is not None and contains_sensitive_path_component(\n        str(resolved)\n    ):\n        raise ValueError(\"Credential or config folders cannot be used for model downloads.\")\n\n    parent = resolved.parent\n    if not parent.exists() or not parent.is_dir():\n        raise ValueError(\"The parent folder does not exist.\")\n    try:","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/utils/hf_cache_settings.py#L237-L273","documentation":"Raised when the resolved cache folder equals its own parent (resolved.parent == resolved), which is only true for a filesystem root such as '/', 'C:\\', or a UNC drive root. The guard exists because using a drive root as a cache home would scatter hub/xet directories and temp files across the root of the volume and break per-volume tooling assumptions.","triggerScenarios":"set_hf_cache_home('/') on Linux/macOS, set_hf_cache_home('C:\\') or 'D:/' on Windows, or any path that resolves to a drive/filesystem root. It fires after successful resolve() but before the sensitive-path and writability checks, so the root case is rejected first.","commonSituations":"A user tries to give the app the whole drive to 'avoid permission problems', or types the mount point of a freshly mounted data disk (e.g. '/mnt/data' is fine, but '/' or a path resolving to a mount root is not). Windows users pasting 'D:' without a subfolder are the classic case.","solutions":["Choose a named subfolder, e.g. '/mnt/data/huggingface' or 'D:\\hf-cache', instead of the drive root","Create the folder first (mkdir) and select it from the folder picker rather than typing the root","If you genuinely want the volume root, accept the restriction and use a one-level-deep directory"],"exampleFix":"# before\nset_hf_cache_home('/')            # ValueError: choose a folder inside the root\n\n# after\nset_hf_cache_home('/hf-cache')    # ok","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef is_root_path(raw: str) -> bool:\n    p = Path(raw).expanduser().resolve(strict=False)\n    return p.parent == p\n\nif is_root_path(user_path): reject with 'pick a subfolder'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default the dialog to a suggested non-root path like ~/.cache/huggingface","Disable the Save button when the picked folder is a drive/mount root"],"tags":["huggingface","cache","path","validation","filesystem-root"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}