github/spec-kit · error · RuntimeError

Command rollback found an unexpected directory at '{original

Error message

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

What it means

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

Source

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

                    backup_created_by_attempt = True
                    backup_file.parent.mkdir(parents=True, exist_ok=True)
                    shutil.copy2(original_file, backup_file)
                backed_up_command_files[original_key] = str(backup_file)

            def restore_command_artifact(original_path, backup_path):
                """Restore one regular file or symlink without following it."""
                original_key = str(original_path)
                original_file = Path(original_path)
                backup_file = Path(backup_path)
                symlink_state = backed_up_command_symlinks.get(
                    original_key
                )

                if symlink_state is not None:
                    if original_file.is_symlink() or original_file.is_file():
                        original_file.unlink()
                    elif original_file.exists():
                        raise RuntimeError(
                            "Command rollback found an unexpected directory "
                            f"at '{original_file}'"
                        )
                    original_file.parent.mkdir(parents=True, exist_ok=True)
                    os.symlink(symlink_state, original_file)
                    return

                if not backup_file.is_file() or backup_file.is_symlink():
                    raise RuntimeError(
                        "Command rollback backup is missing for "
                        f"'{original_file}'"
                    )
                if original_file.is_symlink() or original_file.is_file():
                    original_file.unlink()
                elif original_file.exists():
                    raise RuntimeError(
                        "Command rollback found an unexpected directory "
                        f"at '{original_file}'"

View on GitHub (pinned to bf88c9f9a8)

Solutions

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

When it happens

Trigger: Thrown at src/specify_cli/extensions/_commands.py:1693 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/6595186c046c35d7. Report an issue: GitHub.