{"record":{"id":"d13198cdf41bc51b","repo":"pytest-dev/pytest","slug":"config-file-inipath-has-an-unsupported-format","errorCode":null,"errorMessage":"Config file '{inipath_}' has an unsupported format. Supported extensions are: {supported}.","messagePattern":"Config file '(.+?)' has an unsupported format\\. Supported extensions are: (.+?)\\.","errorType":"validation","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/findpaths.py","lineNumber":447,"sourceCode":"    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``.\n            inicfg = {}\n        if rootdir_cmd_arg is None:\n            if inipath_.is_file():\n                rootdir = inipath_.parent\n            else:\n                # Such a path also says nothing about where the project lives,\n                # so the rootdir must not be derived from it -- otherwise\n                # ``--config-file=/dev/null`` roots at ``/dev`` and the cache\n                # plugin warns that it cannot write ``/dev/.pytest_cache``\n                # (#11502).","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/findpaths.py#L429-L465","documentation":"After confirming the -c target is a regular file, pytest looks up a loader by extension (CONFIG_LOADERS_BY_SUFFIX: typically .ini/.toml/.cfg/.txt). If the extension has no registered loader, it raises UsageError listing the supported extensions so the user knows what to rename or convert to.","triggerScenarios":"pytest -c config.yaml or config.json; a file with no extension; an unusual extension like .conf not in the supported set.","commonSituations":"Migrating config to YAML/JSON (unsupported); pointing -c at a random file; renaming pytest.ini to pytest.local.","solutions":["Rename or convert the file to a supported extension: .ini, .toml, .cfg, or .txt as listed in the message.","If you genuinely want no config from that path, point at /dev/null: pytest -c /dev/null.","Move the settings into a pyproject.toml [tool.pytest.ini_options] table and drop the -c flag."],"exampleFix":"// before\npytest -c config.yaml\n// after\npytest -c config.toml   # after converting the file to TOML","handlingStrategy":"validation","validationCode":"import pathlib\n\nSUPPORTED = {'.ini', '.toml', '.cfg', '.txt'}\n\ndef validate_config_suffix(p: str) -> None:\n    suffix = pathlib.Path(p).suffix\n    assert suffix in SUPPORTED, f'unsupported config suffix {suffix!r}; use one of {SUPPORTED}'","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Keep config in one of the supported extensions.","If migrating, convert contents rather than just renaming."],"tags":["cli","config","file-format"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}