run-llama/llama_index · error · ValueError
File {path} does not exist.
Error message
File {path} does not exist. What it means
During SimpleDirectoryReader construction, each path in input_files is checked with fs.isfile(path); a path that is not an existing file raises ValueError('File {path} does not exist.'). This is eager validation so failures surface before any loading starts.
Source
Thrown at llama-index-core/llama_index/core/readers/file/base.py:290
self.fs = fs or get_default_fs()
self.errors = errors
self.encoding = encoding
self.exclude = exclude
self.recursive = recursive
self.exclude_hidden = exclude_hidden
self.exclude_empty = exclude_empty
self.required_exts = required_exts
self.num_files_limit = num_files_limit
self.raise_on_error = raise_on_error
_Path = Path if is_default_fs(self.fs) else PurePosixPath
if input_files:
self.input_files = []
for path in input_files:
if not self.fs.isfile(path):
raise ValueError(f"File {path} does not exist.")
input_file = _Path(path)
self.input_files.append(input_file)
elif input_dir:
if not self.fs.isdir(input_dir):
raise ValueError(f"Directory {input_dir} does not exist.")
self.input_dir = _Path(input_dir)
self.exclude = exclude
self.input_files = self._add_files(self.input_dir)
self.file_extractor = file_extractor or {}
self.file_metadata = file_metadata or _DefaultFileMetadataFunc(self.fs)
self.filename_as_id = filename_as_id
def is_hidden(self, path: Path | PurePosixPath) -> bool:
return any(
part.startswith(".") and part not in [".", ".."] for part in path.parts
)
View on GitHub (pinned to afd0fef371)
Solutions
- Check paths before constructing: [p for p in files if Path(p).is_file()] or pre-resolve with Path(...).resolve()
- Use absolute paths (e.g. build them from a project-root anchor) instead of cwd-relative ones
- When using a custom fsspec fs, pass paths as that filesystem expects (scheme/keys), since fs.isfile is what validates
Example fix
// before
reader = SimpleDirectoryReader(input_files=["data/report.pdf"]) # cwd mismatch -> raises
// after
from pathlib import Path
root = Path(__file__).parent
files = [str(p) for p in (root / "data").glob("*.pdf") if p.is_file()]
reader = SimpleDirectoryReader(input_files=files) Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
files = [Path(p) for p in input_files]
missing = [p for p in files if not p.is_file()]
if missing:
raise FileNotFoundError(f"missing input files: {missing}")
reader = SimpleDirectoryReader(input_files=[str(p) for p in files]) Try / catch
try:
reader = SimpleDirectoryReader(input_files=files)
except ValueError as e:
if "does not exist" in str(e):
files = [f for f in files if Path(f).is_file()]
if not files:
raise
reader = SimpleDirectoryReader(input_files=files)
else:
raise Prevention
- Resolve paths to absolute form at process start (anchor to project root or __file__)
- Filter/validate file lists before constructing the reader
- Remember the check runs in the constructor — failures are eager, so catch them at setup, not per-query
When it happens
Trigger: Passing input_files=["data/report.pdf"] where the file was moved/deleted, the relative path is resolved from a different working directory, or a remote fsspec filesystem (fs=...) is given local-style paths.
Common situations: Relative paths breaking when the process cwd differs (cron jobs, notebooks run from another directory), stale file lists, or using a custom fs while passing paths valid only on local disk.
Related errors
- Must provide either `input_dir` or `input_files`.
- Max iterations of {max_iterations} reached! Either something
- All agents must have a name in a multi-agent workflow
- All agents must have a description in a multi-agent workflow
- Initial state is not supported per-agent in AgentWorkflow
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/eaf8805622d1f94d.
Report an issue: GitHub.