{"record":{"id":"0c5c32e89c21f42f","repo":"Fission-AI/OpenSpec","slug":"failed-to-install-the-forked-schema-and-could-not","errorCode":null,"errorMessage":"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}","messagePattern":"Failed to install the forked schema and could not restore the previous '(.+?)'\\. Your previous schema is preserved at (.+?); move it back to (.+?) to restore\\. Restore error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/commands/schema.ts","lineNumber":850,"sourceCode":"                `Schema '${destinationName}' at ${destinationDir} changed on disk while the fork was being prepared. ` +\n                  `Aborted to preserve those concurrent changes; nothing was overwritten. Re-run the fork to overwrite the current contents.`\n              );\n            }\n\n            const backupDir = `${destinationDir}.fork-backup-${process.pid}-${Date.now()}`;\n            fs.renameSync(destinationDir, backupDir);\n            try {\n              fs.renameSync(stagingDir, destinationDir);\n            } catch (installError) {\n              // Install failed after the original was moved aside. Try to move\n              // it back. If that restore ALSO fails, the original is stranded in\n              // the backup dir — surface an error naming both the backup and the\n              // destination so the user can recover manually, and attach the\n              // original install error as the cause. Never swallow this.\n              try {\n                fs.renameSync(backupDir, destinationDir);\n              } catch (restoreError) {\n                throw new Error(\n                  `Failed to install the forked schema and could not restore the previous '${destinationName}'. ` +\n                    `Your previous schema is preserved at ${backupDir}; move it back to ${destinationDir} to restore. ` +\n                    `Restore error: ${(restoreError as Error).message}`,\n                  { cause: installError }\n                );\n              }\n              throw installError;\n            }\n\n            // Revalidate before discarding the backup: only delete it if it is\n            // still byte-for-byte the original destination we moved aside. If it\n            // changed during the install window (a concurrent write to the\n            // moved-aside directory), do NOT delete it — leave it in place and\n            // surface where it is so nothing is lost.\n            if (fingerprintDir(backupDir) === authorizedDestinationFingerprint) {\n              fs.rmSync(backupDir, { recursive: true, force: true });\n            } else {\n              console.error(","sourceCodeStart":832,"sourceCodeEnd":868,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/commands/schema.ts#L832-L868","documentation":"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}\" thrown in Fission-AI/OpenSpec.","triggerScenarios":"Thrown at src/commands/schema.ts:850 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-08-25T16:17:27.014Z"}