{"record":{"id":"06c1142d960c55d7","repo":"pytest-dev/pytest","slug":"config-file-inipath-is-a-directory-check-you","errorCode":null,"errorMessage":"Config file '{inipath_}' is a directory. Check your '-c/--config-file' option.","messagePattern":"Config file '(.+?)' is a directory\\. Check your '-c/--config-file' option\\.","errorType":"validation","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/findpaths.py","lineNumber":437,"sourceCode":"        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            )\n        else:\n            # A file pytest has no loader for is an error, but a path that is\n            # not a regular file to begin with cannot hold configuration at\n            # all: it is the way to ask for no configuration, as with\n            # ``--config-file=/dev/null``.","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/findpaths.py#L419-L455","documentation":"pytest explicitly checks is_dir() on the -c/--config-file target and rejects directories. A config file must be a regular file so pytest can pick a loader by extension. The error redirects the user to check the -c option.","triggerScenarios":"Passing a directory path to -c (pytest -c tests/); a glob expanding to a directory; copying a command from docs that used a dir placeholder.","commonSituations":"Confusing --rootdir (a directory) with -c (a file); pointing -c at a conftest directory.","solutions":["Point -c at a specific config file inside the directory, e.g. pytest -c tests/pytest.ini.","If you meant to set the root, use --rootdir=<dir> instead.","If you want no config, use --config-file=/dev/null."],"exampleFix":"// before\npytest -c tests/\n// after\npytest -c tests/pytest.ini\n# or\npytest --rootdir=tests/","handlingStrategy":"validation","validationCode":"import os, pathlib\n\ndef validate_config_not_dir(p: str) -> None:\n    ap = pathlib.Path(os.path.abspath(p))\n    assert not ap.is_dir(), f'-c target is a directory: {ap}; pass a file path'","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Distinguish -c (file) from --rootdir (directory).","Always pass a file path, not a directory, to -c."],"tags":["cli","config","path"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}