Fission-AI/OpenSpec · error · Error

Could not safely stage

Error message

Could not safely stage ${src} before the fallback archive copy (${stageError instanceof Error ? stageError.message : String(stageError)}). No fallback copy was attempted.

What it means

Thrown by moveDirectory when the rename fallback (EPERM/EXDEV) cannot stage the source via a temporary .openspec-move-* directory. No fallback copy is attempted, so the original change directory is left in place and the staging error detail is embedded in the message.

Solutions

  1. Check the stage error detail (permissions, disk space) and fix the cause
  2. Retry the archive; the source was left untouched
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/core/archive.ts:501 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/318920fcfeca6c80. Report an issue: GitHub.

Appendix: source

Thrown at src/core/archive.ts:501

): Promise<void> {
  try {
    await fs.rename(src, dest);
  } catch (err: any) {
    const code = err?.code;
    // rename onto a non-empty directory: the destination was taken while the
    // archive was running. Same condition the pre-flight check reports.
    if (code === 'ENOTEMPTY' || code === 'EEXIST') {
      throw new ArchiveBlockedError(
        'archive_target_exists',
        `Archive '${path.basename(dest)}' already exists.`
      );
    }
    if (code === 'EPERM' || code === 'EXDEV') {
      const stagedSource = path.join(path.dirname(src), `.openspec-move-${randomUUID()}`);
      try {
        await fs.rename(src, stagedSource);
      } catch (stageError) {
        throw new Error(
          `Could not safely stage ${src} before the fallback archive copy ` +
            `(${stageError instanceof Error ? stageError.message : String(stageError)}). ` +
            'No fallback copy was attempted.'
        );
      }
      let destIsOurs = false;
      let stagedFingerprint: string;
      try {
        stagedFingerprint = await fingerprintDirectoryContents(stagedSource);
        await fs.mkdir(dest, { mode: 0o700 });
        destIsOurs = true;
        await copyDirContents(stagedSource, dest);
        await options.verifyCopiedDestination?.(stagedSource);
        await assertCopiedDirectoryUnchanged(stagedSource, dest, stagedFingerprint);
      } catch (copyError) {
        if (destIsOurs) {
          await fs.rm(dest, { recursive: true, force: true }).catch(() => undefined);
        }

View on GitHub (pinned to 6926ccb18a)