rust-lang/rust · error · FailedCheck
File does not exist {!r}
Error message
File does not exist {!r} What it means
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).
Source
Thrown at src/etc/htmldocck.py:260
else:
return self.last_path
def get_absolute_path(self, path):
if "*" in path:
paths = list(Path(self.root).glob(path))
if len(paths) != 1:
raise FailedCheck("glob path does not resolve to one file")
return str(paths[0])
return os.path.join(self.root, path)
def get_file(self, path):
path = self.resolve_path(path)
if path in self.files:
return self.files[path]
abspath = self.get_absolute_path(path)
if not (os.path.exists(abspath) and os.path.isfile(abspath)):
raise FailedCheck("File does not exist {!r}".format(path))
with io.open(abspath, encoding="utf-8") as f:
data = f.read()
self.files[path] = data
return data
def get_tree(self, path):
path = self.resolve_path(path)
if path in self.trees:
return self.trees[path]
abspath = self.get_absolute_path(path)
if not (os.path.exists(abspath) and os.path.isfile(abspath)):
raise FailedCheck("File does not exist {!r}".format(path))
with io.open(abspath, encoding="utf-8") as f:
try:
tree = ET.fromstringlist(f.readlines(), CustomHTMLParser())View on GitHub (pinned to 7088e4b63a)
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.
Example fix
// before //@ has: foo/index.html 'Welcome' // after (after inspecting the output dir) //@ has: foo/foo.index.html 'Welcome'
Defensive patterns
Strategy: validation
Validate before calling
import os
def file_exists_under(root, path) -> bool:
abspath = os.path.join(root, path) if '*' not in path else path
return os.path.exists(abspath) and os.path.isfile(abspath)
if not file_exists_under(doc_root, directive_path):
raise SystemExit(f"htmldocck directive references missing file: {directive_path!r}") Type guard
null
Try / catch
from srcetc_htmldocck import FailedCheck
try:
data = cache.get_file(path)
except FailedCheck as e:
if "File does not exist" in str(e):
logging.error("doc output missing %s; check rustdoc step and layout", path)
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Tried to use the previous path in the first command
- glob path does not resolve to one file
- Directory does not exist {!r}
- line {}: {}
- Non-absolute XPath is not supported due to implementation is
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/b012922d1d899f4f.
Report an issue: GitHub.