fishaudio/fish-speech · error · FileNotFoundError

Directory {path} does not exist.

Error message

Directory {path} does not exist.

What it means

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.

Source

Thrown at fish_speech/utils/file.py:79

    sort: bool = True,
) -> list[Path]:
    """List files in a directory.

    Args:
        path (Path): Path to the directory.
        extensions (set, optional): Extensions to filter. Defaults to None.
        recursive (bool, optional): Whether to search recursively. Defaults to False.
        sort (bool, optional): Whether to sort the files. Defaults to True.

    Returns:
        list: List of files.
    """

    if isinstance(path, str):
        path = Path(path)

    if not path.exists():
        raise FileNotFoundError(f"Directory {path} does not exist.")

    globber = path.rglob if recursive else path.glob
    files = [file for ext in extensions for file in globber(f"*{ext}")]

    if sort:
        files = natsorted(files)

    return files


def load_filelist(path: Path | str) -> list[tuple[Path, str, str, str]]:
    """
    Load a Bert-VITS2 style filelist.
    """

    files = set()
    results = []
    count_duplicated, count_not_found = 0, 0

View on GitHub (pinned to befe400174)

Solutions

  1. Check the directory exists (and create it with mkdir(parents=True, exist_ok=True) if it's an output you're about to populate)
  2. Verify the path/id spelling and that the working directory is correct
  3. Use absolute paths for data roots

Example fix

# before
files = list_files("references/my-id", extensions=[".wav"])
# after
p = Path("references/my-id")
p.mkdir(parents=True, exist_ok=True)
files = list_files(p, extensions=[".wav"])
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
if not path.exists():
    path.mkdir(parents=True, exist_ok=True)  # if it's an output dir
# or: raise a friendly error before calling list_files

Try / catch

try:
    files = list_files(path, extensions)
except FileNotFoundError:
    files = []  # treat missing dir as empty

Prevention

When it happens

Trigger: 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.

Common situations: First run before any reference audio is saved; wrong working directory making a relative path resolve elsewhere; deleted or moved data folders.

Related errors


AI-assisted analysis of fishaudio/fish-speech@befe400174 (2026-08-27). Data as JSON: /api/errors/b9096d953ffc2f60. Report an issue: GitHub.