{"record":{"id":"810424e2ffd3802e","repo":"paperclipai/paperclip","slug":"working-directory-does-not-exist-cwd","errorCode":null,"errorMessage":"Working directory does not exist: \"${cwd}\"","messagePattern":"Working directory does not exist: \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-utils/src/server-utils.ts","lineNumber":2441,"sourceCode":"  if (!path.isAbsolute(cwd)) {\n    throw new Error(`Working directory must be an absolute path: \"${cwd}\"`);\n  }\n\n  const assertDirectory = async () => {\n    const stats = await fs.stat(cwd);\n    if (!stats.isDirectory()) {\n      throw new Error(`Working directory is not a directory: \"${cwd}\"`);\n    }\n  };\n\n  try {\n    await assertDirectory();\n    return;\n  } catch (err) {\n    const code = (err as NodeJS.ErrnoException).code;\n    if (!opts.createIfMissing || code !== \"ENOENT\") {\n      if (code === \"ENOENT\") {\n        throw new Error(`Working directory does not exist: \"${cwd}\"`);\n      }\n      throw err instanceof Error ? err : new Error(String(err));\n    }\n  }\n\n  try {\n    await fs.mkdir(cwd, { recursive: true });\n    await assertDirectory();\n  } catch (err) {\n    const reason = err instanceof Error ? err.message : String(err);\n    throw new Error(`Could not create working directory \"${cwd}\": ${reason}`);\n  }\n}\n\nexport async function resolvePaperclipSkillsDir(\n  moduleDir: string,\n  additionalCandidates: string[] = [],\n): Promise<string | null> {","sourceCodeStart":2423,"sourceCodeEnd":2459,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/adapter-utils/src/server-utils.ts#L2423-L2459","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass { createIfMissing: true } if the directory is allowed to be created.","Run the upstream step that is supposed to create the directory (clone, init, bootstrap) before this call.","Verify the volume/mount backing the path is mounted.","If pre-existence is required, fix the provisioning pipeline so the directory exists by the time this runs."],"exampleFix":"// before\nawait ensureAbsoluteDirectory(cwd);\n// after\nawait ensureAbsoluteDirectory(cwd, { createIfMissing: true });","handlingStrategy":"validation","validationCode":"try {\n  await fs.stat(cwd);\n} catch (err) {\n  if ((err as NodeJS.ErrnoException).code === 'ENOENT' && canCreate) {\n    await fs.mkdir(cwd, { recursive: true });\n  } else { throw err; }\n}","typeGuard":null,"tryCatchPattern":"try { await ensureAbsoluteDirectory(cwd); } catch (err) { if (/does not exist/.test((err as Error).message)) { await ensureAbsoluteDirectory(cwd, { createIfMissing: true }); } else throw err; }","preventionTips":["Pass { createIfMissing: true } when the directory may legitimately not exist yet.","Run workspace bootstrap before invoking the spawn path.","Verify mount points exist before first run."],"tags":["filesystem","path","working-directory","enoent"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}