{"record":{"id":"8e21ffcc62eb2c33","repo":"pytest-dev/pytest","slug":"config-file-inipath-not-found-check-your-c","errorCode":null,"errorMessage":"Config file '{inipath_}' not found. Check your '-c/--config-file' option.","messagePattern":"Config file '(.+?)' not found\\. Check your '-c/--config-file' option\\.","errorType":"validation","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/findpaths.py","lineNumber":432,"sourceCode":"    :param override_ini:\n        The -o/--override-ini command line arguments, if given.\n    :param args:\n        The free command line arguments.\n    :param rootdir_cmd_arg:\n        The `--rootdir` command line argument, if given.\n    :param invocation_dir:\n        The working directory when pytest was invoked.\n\n    :raises UsageError:\n    \"\"\"\n    rootdir = None\n    dirs = get_dirs_from_args(args)\n    ignored_config_files: Sequence[str] = []\n\n    if inifile:\n        inipath_ = absolutepath(inifile)\n        if not inipath_.exists():\n            raise UsageError(\n                f\"Config file '{inipath_}' not found. \"\n                f\"Check your '-c/--config-file' option.\"\n            )\n        if inipath_.is_dir():\n            raise UsageError(\n                f\"Config file '{inipath_}' is a directory. \"\n                f\"Check your '-c/--config-file' option.\"\n            )\n        inipath: Path | None = inipath_\n        loader = _get_config_loader(inipath_)\n        if loader is not None:\n            inicfg = loader(inipath_) or {}\n        elif inipath_.is_file():\n            supported = \", \".join(sorted(CONFIG_LOADERS_BY_SUFFIX))\n            raise UsageError(\n                f\"Config file '{inipath_}' has an unsupported format. \"\n                f\"Supported extensions are: {supported}.\"\n            )","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/findpaths.py#L414-L450","documentation":"When -c/--config-file is given, pytest resolves the path to an absolute path and verifies existence. If the file does not exist, it raises UsageError naming the path and pointing at the -c option. This fails fast rather than silently searching for config elsewhere.","triggerScenarios":"pytest -c pytest-ci.ini where that file was never created; relative path resolved against an unexpected cwd; typo in the filename; CI checked out a branch missing the config file.","commonSituations":"Wrong working directory in CI; renamed config file but not the -c argument; missing config in a fresh shallow clone.","solutions":["Verify the file exists from the directory where pytest runs: ls -la <path>.","Use an absolute path or a path relative to the invocation dir that you have confirmed.","If you want no config, point at /dev/null (--config-file=/dev/null) instead of a missing file."],"exampleFix":"// before\npytest -c config/pytest.ini\n// after\npytest -c $(pwd)/config/pytest.ini   # after confirming the file is present","handlingStrategy":"validation","validationCode":"import os, pathlib\n\ndef validate_config_file(p: str) -> None:\n    ap = pathlib.Path(os.path.abspath(p))\n    assert ap.is_file(), f'config file not found: {ap}'","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use absolute paths for -c in CI scripts.","Verify the config file exists in the checkout before invoking pytest."],"tags":["cli","config","path","ci"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}