{"record":{"id":"b012922d1d899f4f","repo":"rust-lang/rust","slug":"file-does-not-exist-r","errorCode":null,"errorMessage":"File does not exist {!r}","messagePattern":"File does not exist (.+?)","errorType":"validation","errorClass":"FailedCheck","httpStatus":null,"severity":"error","filePath":"src/etc/htmldocck.py","lineNumber":260,"sourceCode":"        else:\n            return self.last_path\n\n    def get_absolute_path(self, path):\n        if \"*\" in path:\n            paths = list(Path(self.root).glob(path))\n            if len(paths) != 1:\n                raise FailedCheck(\"glob path does not resolve to one file\")\n            return str(paths[0])\n        return os.path.join(self.root, path)\n\n    def get_file(self, path):\n        path = self.resolve_path(path)\n        if path in self.files:\n            return self.files[path]\n\n        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            data = f.read()\n            self.files[path] = data\n            return data\n\n    def get_tree(self, path):\n        path = self.resolve_path(path)\n        if path in self.trees:\n            return self.trees[path]\n\n        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())","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/etc/htmldocck.py#L242-L278","documentation":"Raised as FailedCheck by CachedFiles.get_file() when the resolved path does not exist or is not a regular file. get_file() is used by string-based directives (has/hasraw/matches/matchesraw with a file argument) to load raw file content for matching. The {!r} is the resolved logical path (relative to the doc root or as given).","triggerScenarios":"A 'has', 'hasraw', 'matches', or 'matchesraw' directive references a file path that does not exist under the doc output directory, or exists but is not a regular file (e.g. a directory). Reached at htmldocck.py:259-260 via check_command's string-test branches.","commonSituations":"The rustdoc output layout changed and the referenced file moved; a typo in the path; the doc generation step was skipped or failed so the file was never produced; the path was written for a different crate/channel.","solutions":["List the doc output directory and confirm the expected file name/path.","Correct the path in the directive to match the actual generated file.","Ensure the rustdoc/rustc step that produces the file ran successfully before htmldocck."],"exampleFix":"// before\n//@ has: foo/index.html 'Welcome'\n\n// after (after inspecting the output dir)\n//@ has: foo/foo.index.html 'Welcome'","handlingStrategy":"validation","validationCode":"import os\n\ndef file_exists_under(root, path) -> bool:\n    abspath = os.path.join(root, path) if '*' not in path else path\n    return os.path.exists(abspath) and os.path.isfile(abspath)\n\nif not file_exists_under(doc_root, directive_path):\n    raise SystemExit(f\"htmldocck directive references missing file: {directive_path!r}\")","typeGuard":"null","tryCatchPattern":"from srcetc_htmldocck import FailedCheck\ntry:\n    data = cache.get_file(path)\nexcept FailedCheck as e:\n    if \"File does not exist\" in str(e):\n        logging.error(\"doc output missing %s; check rustdoc step and layout\", path)\n    raise","preventionTips":["Confirm the rustdoc output file exists before authoring a directive against it.","Keep directive paths in sync with the current rustdoc output layout.","Run the doc generation step as a prerequisite gate before htmldocck in CI."],"tags":["htmldocck","rustdoc","filesystem","path","test-template"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}