{"record":{"id":"d43f962694ffa76a","repo":"Unity-Technologies/ml-agents","slug":"the-demonstration-file-or-directory-path-does-no","errorCode":null,"errorMessage":"The demonstration file or directory {path} does not exist.","messagePattern":"The demonstration file or directory (.+?) does not exist\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"ml-agents/mlagents/trainers/demo_loader.py","lineNumber":168,"sourceCode":"    :return: List of demonstration files\n\n    Raises errors if |path| is invalid.\n    \"\"\"\n    if os.path.isfile(path):\n        if not path.endswith(\".demo\"):\n            raise ValueError(\"The path provided is not a '.demo' file.\")\n        return [path]\n    elif os.path.isdir(path):\n        paths = [\n            os.path.join(path, name)\n            for name in os.listdir(path)\n            if name.endswith(\".demo\")\n        ]\n        if not paths:\n            raise ValueError(\"There are no '.demo' files in the provided directory.\")\n        return paths\n    else:\n        raise FileNotFoundError(\n            f\"The demonstration file or directory {path} does not exist.\"\n        )\n\n\n@timed\ndef load_demonstration(\n    file_path: str,\n) -> Tuple[BehaviorSpec, List[AgentInfoActionPairProto], int]:\n    \"\"\"\n    Loads and parses a demonstration file.\n    :param file_path: Location of demonstration file (.demo).\n    :return: BrainParameter and list of AgentInfoActionPairProto containing demonstration data.\n    \"\"\"\n\n    # First 32 bytes of file dedicated to meta-data.\n    file_paths = get_demo_files(file_path)\n    behavior_spec = None\n    brain_param_proto = None","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/demo_loader.py#L150-L186","documentation":"get_demo_files raises this FileNotFoundError when the provided path is neither an existing file nor an existing directory, i.e. the demonstration path does not exist on disk. It is the standard 'bad path' guard before any parsing is attempted.","triggerScenarios":"Calling load_demonstration / demo_to_buffer with a path that does not exist, e.g. 'demos/typo_demo.demo', a deleted file, or a path with wrong case on a case-sensitive filesystem.","commonSituations":"Typo in demo_path in the trainer YAML; running training from a different working directory so relative paths resolve incorrectly; demo files removed during cleanup or not copied into a Docker image.","solutions":["Check the path exists with os.path.exists and fix any typos in demo_path.","Use an absolute path (os.path.abspath) in the trainer config to avoid working-directory surprises.","Re-record or re-copy the demonstration file if it was deleted or never mounted into the environment/container."],"exampleFix":"// before\ntrainer_config.demo_path = \"demo/demost3.record\"  # wrong name\n// after\ntrainer_config.demo_path = os.path.abspath(\"demo/demonstrations/demo.demo\")","handlingStrategy":"validation","validationCode":"import os\npath = os.path.abspath(trainer_config[\"demo_path\"])\nif not os.path.exists(path):\n    raise FileNotFoundError(f\"demo_path does not exist: {path}\")","typeGuard":"def demo_path_exists(path: str) -> bool:\n    return os.path.exists(os.path.abspath(path))","tryCatchPattern":"try:\n    demo_spec, pairs, _ = load_demonstration(demo_path)\nexcept FileNotFoundError as e:\n    logger.error(f\"Demo path not found: {demo_path}; check working directory and spelling\")\n    raise SystemExit(1)","preventionTips":["Use absolute paths (os.path.abspath) for demo_path in trainer configs","Verify demo files survived cleanup scripts and container builds","Run a path-existence sanity check at config-load time before training"],"tags":["ml-agents","file-path","demonstrations","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}