Fission-AI/OpenSpec · error

Could not retire capability

Error message

Could not retire capability '${update.id}': failed to delete ${update.target} (${(error as Error).message}). Remove it by hand, then rerun the archive.

What it means

Thrown during spec retirement when the final unlink (or deferred delete) of the target file failed — the wrapped filesystem error is included. The archive cannot complete the removal; the message instructs manual cleanup followed by a rerun.

Solutions

  1. Delete the reported file manually, then rerun the archive
  2. Check for filesystem errors, immutable flags, or permission problems preventing unlink
  3. Retry after resolving the underlying delete error in the message
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/core/specs-apply.ts:870 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/2bcb679f2e4211c1. Report an issue: GitHub.

Appendix: source

Thrown at src/core/specs-apply.ts:870

          await fs.lstat(update.target);
          throw new Error(
            `${error instanceof Error ? error.message : String(error)} ` +
              `A concurrent file now occupies ${update.target}; the displaced spec was retained at ${displaced}.`
          );
        } catch (targetError) {
          if ((targetError as NodeJS.ErrnoException).code !== 'ENOENT') throw targetError;
        }
        await fs.rename(displaced, update.target);
        throw error;
      }
    } else {
      await fs.unlink(update.target);
    }
  } catch (error) {
    if ((error as NodeJS.ErrnoException).code === 'ENOENT') return { retired: false };
    // A bare errno here reads as an internal failure; say what was being
    // attempted so the message is actionable on its own.
    throw new Error(
      `Could not retire capability '${update.id}': failed to delete ${update.target} ` +
        `(${(error as Error).message}). Remove it by hand, then rerun the archive.`
    );
  }

  if (!options.deferDelete) {
    await pruneEmptyDirs(path.dirname(update.target), mainSpecsDir);
  }

  const nominal = options.displayPath ?? `openspec/specs/${update.id}/spec.md`;
  if (!options.silent) {
    console.log(`Retiring ${nominal}: all requirements removed.`);
  }
  // `resolvedPath` is always the file that was actually unlinked - callers need
  // it to report a path git will accept, since the nominal one is built from
  // the capability id and can differ in case, or point through a symlink.
  return {
    retired: true,

View on GitHub (pinned to 6926ccb18a)