oraios/serena · error · FileExistsError

{user_prompt_yaml_path} already exists.

Error message

{user_prompt_yaml_path} already exists.

What it means

`serena prompts create-override` copies an internal prompt template into the user's prompts directory so it can be customized. If a user prompt YAML with the same name already exists, a FileExistsError is raised to avoid silently overwriting customizations.

Source

Thrown at src/serena/cli.py:1431

    @staticmethod
    @click.command(
        "create-override",
        help="Create an override of an internal prompts yaml for customizing Serena's prompts",
        context_settings={"max_content_width": _MAX_CONTENT_WIDTH},
    )
    @click.argument("prompt_yaml_name")
    def create_override(prompt_yaml_name: str) -> None:
        """
        :param prompt_yaml_name: The yaml name of the prompt you want to override. Call the `list` command for discovering valid prompt yaml names.
        :return:
        """
        # for convenience, we can pass names without .yml
        if not prompt_yaml_name.endswith(".yml"):
            prompt_yaml_name = prompt_yaml_name + ".yml"
        user_prompt_yaml_path = PromptCommands._get_user_prompt_yaml_path(prompt_yaml_name)
        if os.path.exists(user_prompt_yaml_path):
            raise FileExistsError(f"{user_prompt_yaml_path} already exists.")
        serena_prompt_yaml_path = os.path.join(PROMPT_TEMPLATES_DIR_INTERNAL, prompt_yaml_name)
        shutil.copyfile(serena_prompt_yaml_path, user_prompt_yaml_path)
        _open_in_editor(user_prompt_yaml_path)

    @staticmethod
    @click.command(
        "edit-override", help="Edit an existing prompt override file", context_settings={"max_content_width": _MAX_CONTENT_WIDTH}
    )
    @click.argument("prompt_yaml_name")
    def edit_override(prompt_yaml_name: str) -> None:
        """
        :param prompt_yaml_name: The yaml name of the prompt override to edit.
        :return:
        """
        # for convenience, we can pass names without .yml
        if not prompt_yaml_name.endswith(".yml"):
            prompt_yaml_name = prompt_yaml_name + ".yml"
        user_prompt_yaml_path = PromptCommands._get_user_prompt_yaml_path(prompt_yaml_name)

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Edit the existing file directly instead of re-running create-override.
  2. Delete or rename the existing override file if you want a fresh copy from the current template.
  3. Use a different prompt name for the new override.
  4. In scripts, check os.path.exists on the target path before invoking, or handle FileExistsError as a no-op.

Example fix

// before
serena prompts create-override system_prompt  # second run -> FileExistsError
// after
# edit ~/.serena/prompts/system_prompt.yml directly, or:
rm ~/.serena/prompts/system_prompt.yml && serena prompts create-override system_prompt
Defensive patterns

Strategy: try-catch

Validate before calling

import os
from serena.prompts import PromptCommands  # or locate the user prompts dir
path = PromptCommands._get_user_prompt_yaml_path('system_prompt')
exists = os.path.exists(path)
if exists:
    print(f'{path} already overridden; edit it directly')

Try / catch

try:
    create_override('system_prompt')
except FileExistsError:
    print('Override already exists; editing existing file instead')

Prevention

When it happens

Trigger: Calling `serena prompts create-override <name>` (with or without the .yml suffix) when `<user_prompts_dir>/<name>.yml` already exists on disk.

Common situations: Running create-override twice for the same prompt; a previous override left behind from an earlier experiment; scripts that re-run setup idempotently without checking.

Related errors


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