github/spec-kit · error · OSError

Failed to stage prior workflow

Error message

Failed to stage prior workflow ({move_exc}); failed to restore it from {backup_file} ({restore_exc}). The prior workflow remains at {backup_file}.

What it means

Error "Failed to stage prior workflow ({move_exc}); failed to restore it from {backup_file} ({restore_exc}). The prior workflow remains at {backup_file}." thrown in github/spec-kit.

Solutions

  1. Manually restore the prior workflow from the reported backup file, then retry the operation.

When it happens

Trigger: Thrown at src/specify_cli/workflows/_commands.py:776 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/883ac74a0578fd1b. Report an issue: GitHub.

Appendix: source

Thrown at src/specify_cli/workflows/_commands.py:776

        finally:
            os.close(fd)
        backup_file = Path(backup_name)
        try:
            os.replace(dest_file, backup_file)
        except BaseException as move_exc:
            backup_state = None
            try:
                backup_state = backup_file.stat(follow_symlinks=False)
            except OSError:
                pass
            if (
                backup_state is not None
                and os.path.samestat(dest_state, backup_state)
            ):
                try:
                    os.replace(backup_file, dest_file)
                except OSError as restore_exc:
                    raise OSError(
                        f"Failed to stage prior workflow ({move_exc}); failed "
                        f"to restore it from {backup_file} ({restore_exc}). "
                        f"The prior workflow remains at {backup_file}."
                    ) from restore_exc
            elif (
                backup_state is not None
                and os.path.samestat(placeholder_state, backup_state)
            ):
                try:
                    backup_file.unlink(missing_ok=True)
                except OSError:
                    pass
            raise
        try:
            if isinstance(staged_file, _StagedWorkflowFile):
                staged_file.verify_path()
                # Windows cannot replace an open file. Verify through the
                # exclusive descriptor, then close immediately before rename.

View on GitHub (pinned to bf88c9f9a8)