oraios/serena · error · FileNotFoundError

Error: Path does not exist: {project_root}

Error message

Error: Path does not exist: {project_root}

What it means

SerenaConfig.add_project_from_path() resolves the given project_root to an absolute path and requires it to exist before registering it. If the path is missing on disk, it raises FileNotFoundError prefixed with 'Error: Path does not exist'.

Source

Thrown at src/serena/config/serena_config.py:1264

        """
        self.projects.append(registered_project)
        self._persist_projects()

    def add_project_from_path(self, project_root: Path | str, asynchronous_autogen: bool = False) -> "Project":
        """
        Adds a new project to the Serena configuration from a given path, auto-generating the project
        with defaults if it does not exist.
        Will raise a FileExistsError if a project already exists at the path.

        :param project_root: the path to the project to add
        :param asynchronous_autogen: whether to use asynchronous auto-generation for the project configuration
        :return: the project that was added
        """
        from ..project import Project

        project_root = Path(project_root).resolve()
        if not project_root.exists():
            raise FileNotFoundError(f"Error: Path does not exist: {project_root}")
        if not project_root.is_dir():
            raise FileNotFoundError(f"Error: Path is not a directory: {project_root}")

        for already_registered_project in self.projects:
            if str(already_registered_project.project_root) == str(project_root):
                raise FileExistsError(
                    f"Project with path {project_root} was already added with name '{already_registered_project.project_name}'."
                )

        autogen = ProjectConfigAutoGenerationMode.ASYNCHRONOUS if asynchronous_autogen else ProjectConfigAutoGenerationMode.SYNCHRONOUS
        project_config = ProjectConfig.load(project_root, serena_config=self, autogen=autogen)

        new_project = Project(
            project_root=str(project_root),
            project_config=project_config,
            is_newly_created=True,
            serena_config=self,
        )

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Correct the path — print the resolved absolute path and verify it exists with os.path.isdir() before calling.
  2. Add the project only after cloning/creating the repository at that location.
  3. If the project moved, remove the stale registration and re-add with the new path.

Example fix

// before
config.add_project_from_path('~/projcts/app')  # typo, does not exist
// after
root = Path('~/projects/app').expanduser().resolve()
assert root.is_dir()
config.add_project_from_path(root)
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
root = Path(project_root).expanduser().resolve()
if not root.exists():
    raise SystemExit(f'project path missing: {root}')

Type guard

def is_existing_path(p) -> bool:
    from pathlib import Path
    try:
        return Path(p).expanduser().resolve().exists()
    except OSError:
        return False

Try / catch

try:
    config.add_project_from_path(project_root)
except FileNotFoundError as e:
    log.error('cannot add project: %s', e)  # create/mount the repo, then retry

Prevention

When it happens

Trigger: Calling add_project_from_path('/nonexistent/dir') or activate_project_from_path_or_name() with a path string that does not exist (typo, deleted/moved repo, wrong mount) — resolved then checked with Path.exists().

Common situations: Typo in the project path; project moved or deleted after being referenced in tooling; relative path resolved from a different working directory than intended; CI container where the repo is not mounted.

Related errors


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