oraios/serena · error · FileNotFoundError

File or directory not found: {abs_path}

Error message

File or directory not found: {abs_path}

What it means

FileNotFoundError raised by the overview-request API when the resolved absolute path (repository_root_path / within_relative_path) does not exist. Unlike [361] this variant resolves with pathlib and reports the resolved absolute path, but the cause is the same: the requested file or directory is missing.

Source

Thrown at src/solidlsp/ls.py:2274

        return result

    def request_document_overview(self, relative_file_path: str) -> list[UnifiedSymbolInformation]:
        """
        :return: the top-level symbols in the given file.
        """
        return self.request_document_symbols(relative_file_path).root_symbols

    def request_overview(self, within_relative_path: str) -> dict[str, list[UnifiedSymbolInformation]]:
        """
        An overview of all symbols in the given file or directory.
        Raises a ValueError if a path to an ignored file is passed.

        :param within_relative_path: the relative path to the file or directory to get the overview of.
        :return: A mapping of all relative paths analyzed to lists of top-level symbols in the corresponding file.
        """
        abs_path = (Path(self.repository_root_path) / within_relative_path).resolve()
        if not abs_path.exists():
            raise FileNotFoundError(f"File or directory not found: {abs_path}")

        if abs_path.is_file():
            if self.is_ignored_path(within_relative_path):
                raise ValueError(f"The explicitly passed file {within_relative_path} is ignored, not returning overview.")
            symbols_overview = self.request_document_overview(within_relative_path)
            return {within_relative_path: symbols_overview}
        else:
            return self.request_dir_overview(within_relative_path)

    def request_hover(
        self, relative_file_path: str, line: int, column: int, file_buffer: LSPFileBuffer | None = None
    ) -> ls_types.Hover | None:
        """
        Raise a [textDocument/hover](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_hover) request to the Language Server
        to find the hover information at the given line and column in the given file. Wait for the response and return the result.

        :param relative_file_path: The relative path of the file that has the hover information
        :param line: The line number of the symbol

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Check (Path(ls.repository_root_path) / rel_path).exists() before calling.
  2. Normalize absolute inputs with os.path.relpath(abs, ls.repository_root_path) and reject out-of-repo paths.
  3. Re-scan the repository to refresh stale paths before requesting overviews.
  4. Verify filename spelling/case (Linux is case-sensitive).

Example fix

// before
ls.request_overview("/abs/path/other/repo/file.py")  # absolute misused
// after
rel = os.path.relpath("/abs/path/other/repo/file.py", ls.repository_root_path)
if not rel.startswith("..") and (Path(ls.repository_root_path) / rel).exists():
    ls.request_overview(rel)
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
abs_p = (Path(ls.repository_root_path) / rel_path).resolve()
if not abs_p.exists():
    raise FileNotFoundError(f"overview target missing: {abs_p}")

Type guard

def overview_target_exists(root: str, rel: str) -> bool:
    return (Path(root) / rel).resolve().exists()

Try / catch

try:
    overview = ls.request_overview(rel_path)
except FileNotFoundError as e:
    logging.warning("cannot overview missing path: %s", e)
    overview = {}

Prevention

When it happens

Trigger: Calling the request_overview-style public method with a within_relative_path that resolves to a nonexistent file/directory — nonexistent path, absolute path misinterpreted as relative, or path deleted between listing and the call.

Common situations: Passing absolute filesystem paths where repo-relative are required, race conditions where files were deleted after a directory scan, branch switches removing files, typos in filenames.

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


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/25d984b68f33784c. Report an issue: GitHub.