Fission-AI/OpenSpec · error · Error
Failed to install the forked schema and could not restore…
Error message
Failed to install the forked schema and could not restore the previous '${destinationName}'. Your previous schema is preserved at ${backupDir}; move it back to ${destinationDir} to restore. Restore error: ${(restoreError as Error).message} What it means
Disaster-path report from the fork swap: installing the staged fork failed AND moving the backup back also failed, so the user is pointed at the retained backup directory as the only copy of the previous schema.
Solutions
- Manually move the backup directory back to the destination path to restore the previous schema
- Re-run the fork once the filesystem issue (e.g. Windows file lock) is resolved
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/commands/schema.ts:850 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Fission-AI/OpenSpec@6926ccb18a (2026-08-25).
Data as JSON: /api/errors/0c5c32e89c21f42f.
Report an issue: GitHub.
Appendix: source
Thrown at src/commands/schema.ts:850
`Schema '${destinationName}' at ${destinationDir} changed on disk while the fork was being prepared. ` +
`Aborted to preserve those concurrent changes; nothing was overwritten. Re-run the fork to overwrite the current contents.`
);
}
const backupDir = `${destinationDir}.fork-backup-${process.pid}-${Date.now()}`;
fs.renameSync(destinationDir, backupDir);
try {
fs.renameSync(stagingDir, destinationDir);
} catch (installError) {
// Install failed after the original was moved aside. Try to move
// it back. If that restore ALSO fails, the original is stranded in
// the backup dir — surface an error naming both the backup and the
// destination so the user can recover manually, and attach the
// original install error as the cause. Never swallow this.
try {
fs.renameSync(backupDir, destinationDir);
} catch (restoreError) {
throw new Error(
`Failed to install the forked schema and could not restore the previous '${destinationName}'. ` +
`Your previous schema is preserved at ${backupDir}; move it back to ${destinationDir} to restore. ` +
`Restore error: ${(restoreError as Error).message}`,
{ cause: installError }
);
}
throw installError;
}
// Revalidate before discarding the backup: only delete it if it is
// still byte-for-byte the original destination we moved aside. If it
// changed during the install window (a concurrent write to the
// moved-aside directory), do NOT delete it — leave it in place and
// surface where it is so nothing is lost.
if (fingerprintDir(backupDir) === authorizedDestinationFingerprint) {
fs.rmSync(backupDir, { recursive: true, force: true });
} else {
console.error(View on GitHub (pinned to 6926ccb18a)