{"record":{"id":"2571a1a68d9e0839","repo":"Unity-Technologies/ml-agents","slug":"config-file-could-not-be-found-at-abs-path","errorCode":null,"errorMessage":"Config file could not be found at {abs_path}.","messagePattern":"Config file could not be found at (.+?)\\.","errorType":"exception","errorClass":"TrainerConfigError","httpStatus":null,"severity":"error","filePath":"ml-agents/mlagents/trainers/cli_utils.py","lineNumber":326,"sourceCode":"\n    torch_conf = argparser.add_argument_group(title=\"Torch Configuration\")\n    torch_conf.add_argument(\n        \"--torch-device\",\n        default=None,\n        dest=\"device\",\n        action=DetectDefault,\n        help='Settings for the default torch.device used in training, for example, \"cpu\", \"cuda\", or \"cuda:0\"',\n    )\n    return argparser\n\n\ndef load_config(config_path: str) -> Dict[str, Any]:\n    try:\n        with open(config_path) as data_file:\n            return _load_config(data_file)\n    except OSError:\n        abs_path = os.path.abspath(config_path)\n        raise TrainerConfigError(f\"Config file could not be found at {abs_path}.\")\n    except UnicodeDecodeError:\n        raise TrainerConfigError(\n            f\"There was an error decoding Config file from {config_path}. \"\n            f\"Make sure your file is save using UTF-8\"\n        )\n\n\ndef _load_config(fp: TextIO) -> Dict[str, Any]:\n    \"\"\"\n    Load the yaml config from the file-like object.\n    \"\"\"\n    try:\n        return yaml.safe_load(fp)\n    except yaml.parser.ParserError as e:\n        raise TrainerConfigError(\n            \"Error parsing yaml file. Please check for formatting errors. \"\n            \"A tool such as http://www.yamllint.com/ can be helpful with this.\"\n        ) from e","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/cli_utils.py#L308-L344","documentation":"mlagents-learn's load_config opens the YAML config file; if the OS reports an error (file missing, permission denied) it wraps it in a TrainerConfigError with the absolute path it tried. This is the standard 'config file not found' failure of the Unity ML-Agents trainer CLI.","triggerScenarios":"Running `mlagents-learn path/to/config.yaml` where the file doesn't exist, the path is relative to a different working directory, or the file is unreadable (permissions). Called by main and from_argparse.","commonSituations":"Typos in --config path, running the CLI from a different cwd than expected, deleted/moved YAML after upgrading, or passing a directory instead of a file.","solutions":["Check the absolute path in the message and verify the file exists: ls <abs_path>","Pass an absolute path or run from the repo root, e.g. mlagents-learn config/ppo/3DBall.yaml --run-id=...","Fix file permissions or point to the correct file","If a directory was passed, specify the YAML file itself"],"exampleFix":"// before\nmlagents-learn ./ppo_config.yaml --run-id=run1   # file not there\n// after\nmlagents-learn /abs/path/config/ppo/3DBall.yaml --run-id=run1","handlingStrategy":"validation","validationCode":"import os\npath = config_path\nif not os.path.isfile(path):\n    raise SystemExit(f\"Trainer config not found: {os.path.abspath(path)}\")\n# then call load_config(path)","typeGuard":null,"tryCatchPattern":"try:\n    config = load_config(config_path)\nexcept TrainerConfigError as e:\n    print(f\"Fix config path: {e}\")\n    sys.exit(2)","preventionTips":["Run mlagents-learn from the directory where the config path resolves, or use absolute paths","Verify the path exists with ls before launching training","Don't pass directories — pass the YAML file itself"],"tags":["config","file-not-found","ml-agents","cli"],"backgroundTag":"config-file-not-found","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}