{"record":{"id":"b9096d953ffc2f60","repo":"fishaudio/fish-speech","slug":"directory-path-does-not-exist","errorCode":null,"errorMessage":"Directory {path} does not exist.","messagePattern":"Directory (.+?) does not exist\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"fish_speech/utils/file.py","lineNumber":79,"sourceCode":"    sort: bool = True,\n) -> list[Path]:\n    \"\"\"List files in a directory.\n\n    Args:\n        path (Path): Path to the directory.\n        extensions (set, optional): Extensions to filter. Defaults to None.\n        recursive (bool, optional): Whether to search recursively. Defaults to False.\n        sort (bool, optional): Whether to sort the files. Defaults to True.\n\n    Returns:\n        list: List of files.\n    \"\"\"\n\n    if isinstance(path, str):\n        path = Path(path)\n\n    if not path.exists():\n        raise FileNotFoundError(f\"Directory {path} does not exist.\")\n\n    globber = path.rglob if recursive else path.glob\n    files = [file for ext in extensions for file in globber(f\"*{ext}\")]\n\n    if sort:\n        files = natsorted(files)\n\n    return files\n\n\ndef load_filelist(path: Path | str) -> list[tuple[Path, str, str, str]]:\n    \"\"\"\n    Load a Bert-VITS2 style filelist.\n    \"\"\"\n\n    files = set()\n    results = []\n    count_duplicated, count_not_found = 0, 0","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/fishaudio/fish-speech/blob/befe4001745417f8c42131739d862b8a6fdbd15a/fish_speech/utils/file.py#L61-L97","documentation":"list_files converts the path to a Path and immediately checks existence, raising FileNotFoundError for a missing directory before any globbing. It is used to load references by id, list reference ids, and in the CLI main.","triggerScenarios":"Calling list_files on a nonexistent directory, e.g. load_by_id with an id whose folder was never created, or passing a wrong --input / data-root.","commonSituations":"First run before any reference audio is saved; wrong working directory making a relative path resolve elsewhere; deleted or moved data folders.","solutions":["Check the directory exists (and create it with mkdir(parents=True, exist_ok=True) if it's an output you're about to populate)","Verify the path/id spelling and that the working directory is correct","Use absolute paths for data roots"],"exampleFix":"# before\nfiles = list_files(\"references/my-id\", extensions=[\".wav\"])\n# after\np = Path(\"references/my-id\")\np.mkdir(parents=True, exist_ok=True)\nfiles = list_files(p, extensions=[\".wav\"])","handlingStrategy":"validation","validationCode":"from pathlib import Path\nif not path.exists():\n    path.mkdir(parents=True, exist_ok=True)  # if it's an output dir\n# or: raise a friendly error before calling list_files","typeGuard":null,"tryCatchPattern":"try:\n    files = list_files(path, extensions)\nexcept FileNotFoundError:\n    files = []  # treat missing dir as empty","preventionTips":["Create output dirs up front","Use absolute paths for data roots"],"tags":["file-system","input-validation","cli"],"backgroundTag":"directory-not-found","analyzedSha":"befe4001745417f8c42131739d862b8a6fdbd15a","analyzedAt":"2026-08-27T21:31:45.703Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}