oraios/serena · error · FileNotFoundError
File or directory not found: {within_abs_path}
Error message
File or directory not found: {within_abs_path} What it means
FileNotFoundError raised by SolidLanguageServer.request_directory_symbols (or similar overview API) when the within_relative_path parameter, joined onto repository_root_path, does not exist on disk. The library validates existence before querying the language server so callers get a clear filesystem error instead of an empty symbol result.
Source
Thrown at src/solidlsp/ls.py:2186
if "location" in node and "relativePath" in node["location"]:
path = Path(node["location"]["relativePath"]) # type: ignore
if path.is_absolute():
try:
path = path.relative_to(self.repository_root_path)
node["location"]["relativePath"] = str(path)
except Exception:
pass
if "children" in node:
fix_relative_path(node["children"])
fix_relative_path(file_root_nodes)
return result
if within_relative_path:
within_abs_path = os.path.join(self.repository_root_path, within_relative_path)
if not os.path.exists(within_abs_path):
raise FileNotFoundError(f"File or directory not found: {within_abs_path}")
if self.is_ignored_path(within_relative_path):
raise ValueError(f"Explicitly requested symbols in '{within_relative_path}' while the path is ignored")
if os.path.isfile(within_abs_path):
root_nodes = self.request_document_symbols(within_relative_path).root_symbols
return root_nodes
else:
self.PathWorkspaceStatus.from_abs_resolved_path(Path(within_abs_path).resolve(), self).check_within_workspace_or_raise()
return process_directory(within_abs_path)
else:
full_result = []
for root in self.config.get_absolute_workspace_folders(self.repository_root_path):
full_result.extend(process_directory(root))
return full_result
@staticmethod
def _get_range_from_file_content(file_content: str) -> ls_types.Range:
"""
Get the range for the given file.View on GitHub (pinned to 7fcbca7e62)
Solutions
- Verify the path exists relative to repository_root_path before calling: os.path.exists(os.path.join(ls.repository_root_path, rel_path)).
- Convert absolute paths to repo-relative: os.path.relpath(abs_path, ls.repository_root_path) (and skip if it starts with '..').
- Fix typos or update the path after refactors; confirm cwd/repository_root_path matches what you assume.
- Ensure the file has been written/saved before requesting symbols for it.
Example fix
// before
ls.request_directory_symbols("src/modle.py") # typo
// after
rel = "src/model.py"
assert os.path.exists(os.path.join(ls.repository_root_path, rel))
ls.request_directory_symbols(rel) Defensive patterns
Strategy: validation
Validate before calling
import os
abs_p = os.path.join(ls.repository_root_path, rel_path)
if not os.path.exists(abs_p):
raise FileNotFoundError(f"{rel_path} does not exist under {ls.repository_root_path}") Type guard
def path_exists_under_repo(root: str, rel: str) -> bool:
return os.path.exists(os.path.join(root, rel)) Try / catch
try:
syms = ls.request_directory_symbols(rel_path)
except FileNotFoundError as e:
logging.warning("path missing: %s", e)
syms = [] Prevention
- Convert absolute paths to repo-relative with os.path.relpath
- Validate path existence before every symbols request
- Re-verify paths after branch switches or refactors
- Watch filename case on case-sensitive filesystems
When it happens
Trigger: Calling request_overview/request_directory_symbols-style APIs with within_relative_path pointing to a file or directory that does not exist under repository_root_path — typo in path, file deleted/moved, or using an absolute path where a repo-relative path is expected.
Common situations: Passing OS-absolute paths as relative paths, stale paths after a refactor or checkout of another branch, typos like 'src/mian.py', or paths outside the repository root.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- File or directory not found: {abs_path}
- Error: Path does not exist: {project_root}
- Error: Path is not a directory: {project_root}
- Specified a relative working directory ({cwd}), but the resu
- Relative path {relative_path} does not exist.
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/aebb5900334a220c.
Report an issue: GitHub.