paperclipai/paperclip · error · Error

Working directory does not exist: "${cwd}"

Error message

Working directory does not exist: "${cwd}"

What it means

Thrown by ensureAbsoluteDirectory when fs.stat raises ENOENT and the caller did not pass createIfMissing:true. The path does not exist on disk and the function was told not to create it, so it fails closed rather than letting downstream operations hit a missing-dir error.

Source

Thrown at packages/adapter-utils/src/server-utils.ts:2441

  if (!path.isAbsolute(cwd)) {
    throw new Error(`Working directory must be an absolute path: "${cwd}"`);
  }

  const assertDirectory = async () => {
    const stats = await fs.stat(cwd);
    if (!stats.isDirectory()) {
      throw new Error(`Working directory is not a directory: "${cwd}"`);
    }
  };

  try {
    await assertDirectory();
    return;
  } catch (err) {
    const code = (err as NodeJS.ErrnoException).code;
    if (!opts.createIfMissing || code !== "ENOENT") {
      if (code === "ENOENT") {
        throw new Error(`Working directory does not exist: "${cwd}"`);
      }
      throw err instanceof Error ? err : new Error(String(err));
    }
  }

  try {
    await fs.mkdir(cwd, { recursive: true });
    await assertDirectory();
  } catch (err) {
    const reason = err instanceof Error ? err.message : String(err);
    throw new Error(`Could not create working directory "${cwd}": ${reason}`);
  }
}

export async function resolvePaperclipSkillsDir(
  moduleDir: string,
  additionalCandidates: string[] = [],
): Promise<string | null> {

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Pass { createIfMissing: true } if the directory is allowed to be created.
  2. Run the upstream step that is supposed to create the directory (clone, init, bootstrap) before this call.
  3. Verify the volume/mount backing the path is mounted.
  4. If pre-existence is required, fix the provisioning pipeline so the directory exists by the time this runs.

Example fix

// before
await ensureAbsoluteDirectory(cwd);
// after
await ensureAbsoluteDirectory(cwd, { createIfMissing: true });
Defensive patterns

Strategy: validation

Validate before calling

try {
  await fs.stat(cwd);
} catch (err) {
  if ((err as NodeJS.ErrnoException).code === 'ENOENT' && canCreate) {
    await fs.mkdir(cwd, { recursive: true });
  } else { throw err; }
}

Try / catch

try { await ensureAbsoluteDirectory(cwd); } catch (err) { if (/does not exist/.test((err as Error).message)) { await ensureAbsoluteDirectory(cwd, { createIfMissing: true }); } else throw err; }

Prevention

When it happens

Trigger: Calling ensureAbsoluteDirectory(cwd) without {createIfMissing:true} for a path that does not yet exist on the filesystem. E.g. a fresh checkout dir, a runtime workspace that was never created, or a path on a volume not yet mounted.

Common situations: First run before any workspace bootstrap; the directory was deleted/cleaned; a mount point is not mounted yet; createIfMissing was intentionally false to enforce pre-existence but the prerequisite setup did not run.

Related errors


AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12). Data as JSON: /api/errors/810424e2ffd3802e. Report an issue: GitHub.