oraios/serena · error · FileNotFoundError
Memory maintenance template not found at {template_path}
Error message
Memory maintenance template not found at {template_path} What it means
ensure_memory_maintenance_memory seeds a project-level memory-maintenance memory by copying a template shipped with the serena package. If the template file at _MEMORY_MAINTENANCE_TEMPLATE_PATH does not exist on disk, FileNotFoundError is raised. This indicates the installation is broken or the template was removed.
Source
Thrown at src/serena/memories/memory_manager.py:118
Existing memory files are never overwritten; users may have customized them. To
refresh from the shipped template, delete the existing memory first.
:return: the bare name to reference the maintenance memory by (without the ``mem:``
prefix); either ``"global/memory_maintenance"`` or ``"memory_maintenance"``.
:raises FileNotFoundError: if the shipped template is missing on disk.
:raises AssertionError: if this manager has no associated project directory.
"""
global_name = f"{self.GLOBAL_TOPIC}/{self.MEMORY_MAINTENANCE_NAME}"
if self.get_memory_file_path(global_name).exists():
return global_name
if self.get_memory_file_path(self.MEMORY_MAINTENANCE_NAME).exists():
return self.MEMORY_MAINTENANCE_NAME
# seed a project copy from the shipped template
template_path = self._MEMORY_MAINTENANCE_TEMPLATE_PATH
if not template_path.exists():
raise FileNotFoundError(f"Memory maintenance template not found at {template_path}")
content = template_path.read_text(encoding=self._encoding)
self.save_memory(self.MEMORY_MAINTENANCE_NAME, content, is_tool_context=False)
return self.MEMORY_MAINTENANCE_NAME
def rename_references_to_memory(self, content: str, old_name: str, new_name: str) -> tuple[str, int]:
r"""
Replaces all occurrences of a memory reference (e.g. ``mem:foo``) in ``content`` with
the reference to ``new_name``.
Matches only references whose name is exactly ``old_name``: the match must not be
embedded in a longer memory name. A memory name consists of the character class
``[A-Za-z0-9_\\-/]`` (alphanumerics, underscore, hyphen, slash for topic separation),
which determines the boundary of the match. The surrounding delimiters (backticks,
quotes, parentheses, whitespace, etc.) are intentionally unconstrained.
:param content: the text to search through
:param old_name: the memory name being renamed away from (without the ``mem:`` prefix)
:param new_name: the memory name being renamed to (without the ``mem:`` prefix)View on GitHub (pinned to 7fcbca7e62)
Solutions
- Reinstall serena cleanly: pip uninstall serena && pip install --force-reinstall serena (or pip install -e . from a fresh checkout).
- Verify the template exists at the path in _MEMORY_MAINTENANCE_TEMPLATE_PATH inside site-packages; if missing, the package data was not shipped.
- If installing from source, ensure the template file is present in src/serena/memories/ and that package-data/include patterns cover .md resources.
- As a workaround, pre-create the memory-maintenance memory in the project (.serena/memories/) so the template copy path is skipped.
Example fix
// before pip install serena # broken wheel without template resources // after pip uninstall -y serena pip install --force-reinstall serena # verify: python -c "import serena.memories, pathlib; print(pathlib.Path(serena.memories.__file__).parent)"
Defensive patterns
Strategy: fallback
Validate before calling
from pathlib import Path
template = manager._MEMORY_MAINTENANCE_TEMPLATE_PATH
if not template.exists():
raise RuntimeError(f"serena install broken: missing {template}; reinstall the package") Type guard
def template_available(manager) -> bool:
return bool(getattr(manager, "_MEMORY_MAINTENANCE_TEMPLATE_PATH", None)
and manager._MEMORY_MAINTENANCE_TEMPLATE_PATH.exists()) Try / catch
try:
name = manager.ensure_memory_maintenance_memory()
except FileNotFoundError:
log.warning("maintenance template missing; skipping seeding")
name = None Prevention
- Reinstall/verify the package after upgrades (pip check, force-reinstall)
- Ensure packaging includes non-.py resources (.md templates)
- Verify template presence in CI before deploying
When it happens
Trigger: Calling ensure_memory_maintenance_memory (directly or via initialize/apply) when the project has no memory-maintenance memory yet AND the bundled template file is missing from the installed package.
Common situations: Partial/broken pip install or wheel build that excluded the template resource; manually deleted files inside the installed serena package; running from a source checkout where the template was moved or not committed; packaging tools (e.g. setuptools without package-data config) that skipped non-.py resources.
Related errors
- Download failed? Could not find clojure-lsp executable at {c
- Roslyn Language Server DLL not found after extraction
- Kotlin Language Server script not found at {kotlin_script}
- This method must be overridden for each subclass
- Context file not found: {path.resolve()}
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/4d7e92f0f3dfc2ec.
Report an issue: GitHub.