{"record":{"id":"5cb4b8ec53f05904","repo":"rust-lang/rust","slug":"directory-does-not-exist-r","errorCode":null,"errorMessage":"Directory does not exist {!r}","messagePattern":"Directory does not exist (.+?)","errorType":"validation","errorClass":"FailedCheck","httpStatus":null,"severity":"error","filePath":"src/etc/htmldocck.py","lineNumber":290,"sourceCode":"        abspath = self.get_absolute_path(path)\n        if not (os.path.exists(abspath) and os.path.isfile(abspath)):\n            raise FailedCheck(\"File does not exist {!r}\".format(path))\n\n        with io.open(abspath, encoding=\"utf-8\") as f:\n            try:\n                tree = ET.fromstringlist(f.readlines(), CustomHTMLParser())\n            except Exception as e:\n                raise RuntimeError(  # noqa: B904 FIXME: py2\n                    \"Cannot parse an HTML file {!r}: {}\".format(path, e)\n                )\n            self.trees[path] = tree\n            return self.trees[path]\n\n    def get_dir(self, path):\n        path = self.resolve_path(path)\n        abspath = self.get_absolute_path(path)\n        if not (os.path.exists(abspath) and os.path.isdir(abspath)):\n            raise FailedCheck(\"Directory does not exist {!r}\".format(path))\n\n\ndef check_string(data, pat, regexp):\n    pat = pat.replace(\"{{channel}}\", channel)\n    if not pat:\n        return True  # special case a presence testing\n    elif regexp:\n        return re.search(pat, data, flags=re.UNICODE) is not None\n    else:\n        data = \" \".join(data.split())\n        pat = \" \".join(pat.split())\n        return pat in data\n\n\ndef check_tree_attr(tree, path, attr, pat, regexp):\n    path = normalize_xpath(path)\n    ret = False\n    for e in tree.findall(path):","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/etc/htmldocck.py#L272-L308","documentation":"Raised as FailedCheck by CachedFiles.get_dir() when the resolved path does not exist or is not a directory. get_dir() backs the 'has-dir' directive, which asserts the presence of a directory in the doc output tree.","triggerScenarios":"A `//@ has-dir: <path>` directive references a directory that does not exist under the doc output root, or exists but is a file rather than a directory. Reached at htmldocck.py:289-290 via the has-dir branch of check_command.","commonSituations":"rustdoc stopped generating that subdirectory (layout/version change); typo in the path; the directory is only created when certain items are documented and the test crate was changed.","solutions":["List the doc output root to confirm whether the directory exists or was renamed.","Correct the path in the has-dir directive.","Ensure the test crate documents at least one item that triggers the directory's generation."],"exampleFix":"// before\n//@ has-dir: foo/structs\n\n// after (after checking the output tree)\n//@ has-dir: foo/struct","handlingStrategy":"validation","validationCode":"import os\n\ndef dir_exists_under(root, path) -> bool:\n    abspath = os.path.join(root, path)\n    return os.path.exists(abspath) and os.path.isdir(abspath)\n\nif not dir_exists_under(doc_root, directive_path):\n    raise SystemExit(f\"htmldocck has-dir references missing directory: {directive_path!r}\")","typeGuard":"null","tryCatchPattern":"from srcetc_htmldocck import FailedCheck\ntry:\n    cache.get_dir(path)\nexcept FailedCheck as e:\n    if \"Directory does not exist\" in str(e):\n        logging.error(\"doc output has no directory %s; check layout/generation\", path)\n    raise","preventionTips":["Confirm the directory is actually generated by rustdoc for the test crate.","Update has-dir paths when the output layout changes.","Ensure the test crate documents items that trigger the directory's creation."],"tags":["htmldocck","rustdoc","filesystem","directory","test-template"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}