github/spec-kit · error · RuntimeError

Command rollback found an unexpected directory at '{command_

Error message

Command rollback found an unexpected directory at '{command_path}'

What it means

Error "Command rollback found an unexpected directory at '{command_path}'" thrown in github/spec-kit.

Source

Thrown at src/specify_cli/extensions/_commands.py:2319

                    # Only perform destructive rollback if backup exists (meaning we
                    # actually modified the extension). This avoids deleting a valid
                    # installation when failure happened before changes were made.
                    extension_dir = manager.extensions_dir / extension_id
                    if backup_ext_dir.exists():
                        if extension_dir.exists():
                            shutil.rmtree(extension_dir)
                        shutil.copytree(backup_ext_dir, extension_dir)

                    # Remove any NEW command files created by failed install
                    # (files that weren't in the original backup). Registration
                    # writes before registry.add(), so start with the paths that
                    # were absent at the destructive boundary instead of relying
                    # only on a possibly missing new registry entry.
                    for command_path in new_command_paths_absent_before_update:
                        if command_path.is_symlink() or command_path.is_file():
                            command_path.unlink()
                        elif command_path.exists():
                            raise RuntimeError(
                                "Command rollback found an unexpected directory "
                                f"at '{command_path}'"
                            )
                    new_registered_skills = []
                    try:
                        new_registry_entry = manager.registry.get(extension_id)
                        if new_registry_entry is None or not isinstance(new_registry_entry, dict):
                            new_registered_commands = {}
                        else:
                            new_registered_commands = new_registry_entry.get("registered_commands", {})
                            new_registered_skills = manager._valid_name_list(
                                new_registry_entry.get("registered_skills", [])
                            )
                        for agent_name, cmd_names in new_registered_commands.items():
                            if agent_name not in registrar.AGENT_CONFIGS:
                                continue
                            agent_config = registrar.AGENT_CONFIGS[agent_name]
                            commands_dir = _AgentReg._resolve_agent_dir(

View on GitHub (pinned to bf88c9f9a8)

Solutions

  1. Remove the unexpected directory at the command path so rollback can restore the file, then retry.

When it happens

Trigger: Thrown at src/specify_cli/extensions/_commands.py:2319 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of github/spec-kit@bf88c9f9a8 (2026-08-14). Data as JSON: /api/errors/badac317ae6acc80. Report an issue: GitHub.