Fission-AI/OpenSpec · error · StoreError

context_output_dir_missing

context_output_dir_missing

Error message

Output directory does not exist: ${parent}.

What it means

Guard in writeCodeWorkspace: the parent directory of the resolved output path does not exist, so the workspace file cannot be written. Fires when the user passes an output path whose directory was never created; the fix is to create the directory (or pick an existing path).

Solutions

  1. Create the output directory first (mkdir -p)
  2. Point --output at an existing directory
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/commands/context.ts:138 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/229c6f1cfda28ba9. Report an issue: GitHub.

Appendix: source

Thrown at src/commands/context.ts:138

function writeCodeWorkspace(
  workingSet: WorkingSet,
  outputPath: string,
  force: boolean
): void {
  const resolved = path.resolve(outputPath);
  if (fs.existsSync(resolved) && !force) {
    throw new StoreError(
      `Refusing to overwrite ${resolved}.`,
      'context_file_exists',
      {
        target: 'context.output',
        fix: `Pass --force to overwrite, or choose a different path.`,
      }
    );
  }
  const parent = path.dirname(resolved);
  if (!fs.existsSync(parent)) {
    throw new StoreError(
      `Output directory does not exist: ${parent}.`,
      'context_output_dir_missing',
      { target: 'context.output', fix: 'Create the directory first, or choose another path.' }
    );
  }

  const rootName = workingSet.root.store_id ?? path.basename(workingSet.root.path);
  fs.writeFileSync(resolved, buildCodeWorkspaceJson(workingSet, rootName));

  const available = workingSet.members.filter(isAvailableMember).length;
  const skipped = workingSet.members
    .filter((member) => !isAvailableMember(member))
    .map((member) => member.id);
  const summary =
    skipped.length > 0
      ? `Wrote ${resolved} (${available + 1} folders; not available: ${skipped.join(', ')})`
      : `Wrote ${resolved} (${available + 1} folders)`;
  // stderr keeps JSON stdout pure; for humans it reads inline.

View on GitHub (pinned to 6926ccb18a)