oraios/serena · error · ValueError
Multiple projects found with name '{project_root_or_name}'.
Error message
Multiple projects found with name '{project_root_or_name}'. Please reference it by location instead. Locations: {[p.project_root for p in project_candidates]} What it means
get_registered_project() resolves a project either by root path or by name. When the given string matches the project_name of more than one registered project, resolution is ambiguous, so it raises ValueError listing all matching roots and asks the caller to reference the project by its location instead.
Source
Thrown at src/serena/config/serena_config.py:1217
def project_names(self) -> list[str]:
return sorted(project.project_config.project_name for project in self.projects)
def get_registered_project(self, project_root_or_name: str, autoregister: bool = False) -> Optional[RegisteredProject]:
"""
:param project_root_or_name: path to the project root or the name of the project
:param autoregister: whether to auto-register projects that are not yet registered in Serena's global configuration
but have an existing project configuration file. Project configuration files are never auto-generated.
:return: the registered project, or None if not found
"""
# look for project by name
project_candidates = []
for project in self.projects:
if project.project_config.project_name == project_root_or_name:
project_candidates.append(project)
if len(project_candidates) == 1:
return project_candidates[0]
elif len(project_candidates) > 1:
raise ValueError(
f"Multiple projects found with name '{project_root_or_name}'. Please reference it by location instead. "
f"Locations: {[p.project_root for p in project_candidates]}"
)
# no project found by name; check if it's a path
if os.path.isdir(project_root_or_name):
for project in self.projects:
if project.matches_root_path(project_root_or_name):
return project
# no registered project found; optionally auto-register if a project configuration already exists
if autoregister:
config_path = self.get_project_yml_location(project_root_or_name)
if os.path.isfile(config_path):
registered_project = RegisteredProject.from_project_root(project_root_or_name, serena_config=self)
self.add_registered_project(registered_project)
return registered_project
# nothing found
return None
View on GitHub (pinned to 7fcbca7e62)
Solutions
- Call with the project's absolute path instead of the name: get_registered_project('/path/to/repo').
- Edit one of the duplicate serena_project.yml files to give it a unique project_name.
- Remove the redundant registration with SerenaConfig.remove_project(name-or-path) and re-add the correct one via add_project_from_path.
Example fix
// before
project = config.get_registered_project('myproj') # ambiguous
// after
project = config.get_registered_project('/home/me/work/myproj') Defensive patterns
Strategy: try-catch
Validate before calling
names = [p.project_config.project_name for p in config.projects] ambiguous = name in names and names.count(name) > 1
Type guard
def is_unambiguous_name(config, name: str) -> bool:
names = [p.project_config.project_name for p in config.projects]
return names.count(name) <= 1 or name in config.project_names Try / catch
try:
project = config.get_registered_project('myproj')
except ValueError as e:
if 'Multiple projects found' in str(e):
project = config.get_registered_project('/abs/path/to/myproj')
else:
raise Prevention
- Give every registered project a unique project_name in its serena_project.yml
- Reference projects by absolute path in scripts instead of by name
- Rename duplicates after cloning/forking a repo
When it happens
Trigger: Calling get_registered_project('myproj') (directly or via activate_project_from_path_or_name / get_project) when two different directories are registered with the same project_name in their serena_project.yml files.
Common situations: Cloning the same repo to two folders (both ymls keep the identical project_name); forking a project without renaming; copying a project directory and its config; team-shared configs registering duplicate names.
Related errors
- Context file not found: {path.resolve()}
- Cannot use both fixed_tools and excluded_tools/included_opti
- Unknown language backend '{backend_str}': valid values are {
- Invalid line_ending: {value!r}. Valid values are: {valid}
- Cannot use interactive mode with asynchronous auto-generatio
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/e5f2c1f3dc431f8f.
Report an issue: GitHub.