{"record":{"id":"28fbdef72ffb0a4e","repo":"pytest-dev/pytest","slug":"directory-rootdir-not-found-check-your-roo","errorCode":null,"errorMessage":"Directory '{rootdir}' not found. Check your '--rootdir' option.","messagePattern":"Directory '(.+?)' not found\\. Check your '--rootdir' option\\.","errorType":"validation","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/findpaths.py","lineNumber":491,"sourceCode":"        )\n        if rootdir is None and rootdir_cmd_arg is None:\n            for possible_rootdir in (ancestor, *ancestor.parents):\n                if (possible_rootdir / \"setup.py\").is_file():\n                    rootdir = possible_rootdir\n                    break\n            else:\n                if dirs != [ancestor]:\n                    rootdir, inipath, inicfg, _ = locate_config(invocation_dir, dirs)\n                if rootdir is None:\n                    rootdir = get_common_ancestor(\n                        invocation_dir, [invocation_dir, ancestor]\n                    )\n                    if is_fs_root(rootdir):\n                        rootdir = ancestor\n    if rootdir_cmd_arg:\n        rootdir = absolutepath(os.path.expandvars(rootdir_cmd_arg))\n        if not rootdir.is_dir():\n            raise UsageError(\n                f\"Directory '{rootdir}' not found. Check your '--rootdir' option.\"\n            )\n\n    ini_overrides = parse_override_ini(override_ini)\n    inicfg.update(ini_overrides)\n\n    assert rootdir is not None\n    return rootdir, inipath, inicfg, ignored_config_files\n\n\ndef is_fs_root(p: Path) -> bool:\n    r\"\"\"\n    Return True if the given path is pointing to the root of the\n    file system (\"/\" on Unix and \"C:\\\\\" on Windows for example).\n    \"\"\"\n    return os.path.splitdrive(str(p))[1] == os.sep\n","sourceCodeStart":473,"sourceCodeEnd":508,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/findpaths.py#L473-L508","documentation":"When --rootdir is passed, pytest resolves it to an absolute path and checks is_dir(). If the directory does not exist, it raises UsageError pointing at the --rootdir option. pytest needs the rootdir to exist because it anchors test paths, cache, and output under it.","triggerScenarios":"pytest --rootdir=/tmp/nonexistent; a relative rootdir resolved from an unexpected cwd; CI workspace layout differs from local.","commonSituations":"CI checkout missing the expected directory; typo in the path; running pytest from a different directory than assumed.","solutions":["Create the directory or correct the path; confirm with ls -d <rootdir>.","Use an absolute path that you have verified exists.","Drop --rootdir to let pytest infer the root from config location and common ancestors."],"exampleFix":"// before\npytest --rootdir=build/out\n// after\nmkdir -p build/out && pytest --rootdir=$(pwd)/build/out","handlingStrategy":"validation","validationCode":"import os, pathlib\n\ndef validate_rootdir(p: str) -> None:\n    ap = pathlib.Path(os.path.abspath(os.path.expandvars(p)))\n    assert ap.is_dir(), f'--rootdir does not exist: {ap}'","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Pre-create output/root directories before invoking pytest.","Use absolute paths in CI to avoid cwd-relative surprises."],"tags":["cli","config","path","ci"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}