{"record":{"id":"7005ad8a3ea6d14f","repo":"oraios/serena","slug":"project-project-root-or-name-not-found-not-a","errorCode":null,"errorMessage":"Project '{project_root_or_name}' not found: Not a valid project name or directory. Existing project names: {self.serena_config.project_names}","messagePattern":"Project '(.+?)' not found: Not a valid project name or directory\\. Existing project names: (.+?)","errorType":"exception","errorClass":"ProjectNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/agent.py","lineNumber":1357,"sourceCode":"        self, project_root_or_name: str, update_active_modes: bool = True, update_active_tools: bool = True\n    ) -> bool:\n        \"\"\"\n        Activate a project from a path or a name.\n        If the project was already registered, it will just be activated.\n        If the argument is a path at which no Serena project previously existed, the project will be created beforehand.\n        Raises ProjectNotFoundError if the project could neither be found nor created.\n\n        :return: True if the project was newly activated, False if it was already active\n        \"\"\"\n        project_instance: Project | None = self.serena_config.get_project(project_root_or_name)\n        if project_instance is not None:\n            log.info(f\"Found registered project '{project_instance.project_name}' at path {project_instance.project_root}\")\n        elif os.path.isdir(project_root_or_name):\n            project_instance = self.serena_config.add_project_from_path(project_root_or_name, asynchronous_autogen=True)\n            log.info(f\"Added new project {project_instance.project_name} for path {project_instance.project_root}\")\n\n        if project_instance is None:\n            raise ProjectNotFoundError(\n                f\"Project '{project_root_or_name}' not found: Not a valid project name or directory. \"\n                f\"Existing project names: {self.serena_config.project_names}\"\n            )\n\n        return self._activate_project(project_instance, update_active_modes=update_active_modes, update_active_tools=update_active_tools)\n\n    def get_active_tool_names(self) -> list[str]:\n        \"\"\"\n        :return: the list of names of the active tools for the current project, sorted alphabetically\n        \"\"\"\n        return self._active_tools.tool_names\n\n    def tool_is_active(self, tool_name: str) -> bool:\n        \"\"\"\n        :param tool_class: the name of the tool to check\n        :return: True if the tool is active, False otherwise\n        \"\"\"\n        return self._active_tools.contains_tool_name(tool_name)","sourceCodeStart":1339,"sourceCodeEnd":1375,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/agent.py#L1339-L1375","documentation":"activate_project_from_path_or_name resolves its argument first as a registered project name, then as a directory path; if neither matches, it raises ProjectNotFoundError listing all registered project names. This guards against typos and paths that don't contain a valid Serena project.","triggerScenarios":"Calling activate_project / activate_project_from_path_or_name with (a) a name not present in serena_config's registered projects and (b) a string that is not an existing directory; also during __init__ when the --project startup flag resolves to nothing.","commonSituations":"Typos in registered project names; passing a relative path instead of an absolute one; passing a file path instead of a directory; the project directory was moved/renamed after registration; the LLM tool supplying a guessed project name.","solutions":["Pass an absolute path to the project root directory (os.path.isdir check must succeed).","Use exactly one of the registered names (check the 'Existing project names' list in the error message or serena_config.yml).","If the project is new, ensure the directory exists and contains (or can autogenerate) .serena/project.yml, then activate by path.","Fix stale registrations pointing at moved directories by re-adding the project with its new path."],"exampleFix":"// before\nagent.activate_project_from_path_or_name('myproj')  # name not registered\n// after\nagent.activate_project_from_path_or_name('/home/user/work/myproj')","handlingStrategy":"validation","validationCode":"def can_activate(agent, name_or_path: str) -> bool:\n    if os.path.isdir(os.path.abspath(name_or_path)):\n        return True\n    return name_or_path in agent.serena_config.project_names","typeGuard":"def is_valid_project_ref(serena_config, ref: str) -> bool:\n    return os.path.isdir(ref) or ref in serena_config.project_names","tryCatchPattern":"try:\n    agent.activate_project_from_path_or_name(ref)\nexcept ProjectNotFoundError:\n    log.error('Unknown project %r; registered: %s', ref, agent.serena_config.project_names)\n    raise","preventionTips":["Always pass absolute directory paths (resolve relative paths before calling).","Verify the name against serena_config.project_names or the error's 'Existing project names' list.","Update stale registrations after moving/renaming project directories.","Register new projects (serena project create or add_project_from_path) before activating by name."],"tags":["project-activation","path-resolution","configuration"],"backgroundTag":"project-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}