{"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":"exception","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/findpaths.py","lineNumber":342,"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":324,"sourceCodeEnd":359,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/findpaths.py#L324-L359","documentation":"Raised when the --rootdir command-line argument points to a path that does not exist or is not a directory. pytest resolves --rootdir to an absolute path and checks is_dir(); a missing directory is rejected immediately rather than silently falling back.","triggerScenarios":"Running pytest --rootdir /nonexistent/path, or --rootdir with a relative path that resolves outside the current working directory, or pointing --rootdir at a file rather than a directory. The check at line 339-344 fails is_dir().","commonSituations":"Typing the wrong path; using a path relative to a different working directory; pointing --rootdir at a file; CI environments where the expected directory isn't checked out; renamed/moved project directories.","solutions":["Verify the path exists: ls /path/to/rootdir before running pytest.","Use a path relative to the invocation directory or an absolute path you have verified.","Remove --rootdir entirely to let pytest auto-determine the rootdir from config/args.","Ensure CI checks out the directory structure your --rootdir assumes."],"exampleFix":"# before\npytest --rootdir /home/me/wrongdir\n\n# after\npytest --rootdir /home/me/myproject\n# or omit it\npytest","handlingStrategy":"validation","validationCode":"import os\nfrom pathlib import Path\ndef validate_rootdir(path_str: str) -> Path:\n    p = Path(os.path.expandvars(path_str)).resolve()\n    if not p.is_dir():\n        raise FileNotFoundError(f\"Directory '{p}' not found. Check your '--rootdir' option.\")\n    return p","typeGuard":"from pathlib import Path\ndef rootdir_exists(path_str: str) -> bool:\n    return Path(path_str).expanduser().is_dir()","tryCatchPattern":null,"preventionTips":["Verify the --rootdir path with ls before invoking pytest.","Prefer relative paths anchored at the invocation directory or use absolute verified paths.","Omit --rootdir to let pytest auto-detect from config files."],"tags":["pytest","config","cli","rootdir","filesystem","usage-error"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}