{"record":{"id":"75ca2566fe3f8f73","repo":"paperclipai/paperclip","slug":"could-not-create-working-directory-cwd-on-rem","errorCode":null,"errorMessage":"Could not create working directory \"${cwd}\" on remote target${detail ? `: ${detail}` : \".\"}","messagePattern":"Could not create working directory \"(.+?)\" on remote target(.+?)` : \"\\.\"\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-utils/src/execution-target.ts","lineNumber":1012,"sourceCode":"  const script = createIfMissing\n    ? `mkdir -p ${quoted} && [ -d ${quoted} ]`\n    : `[ -d ${quoted} ]`;\n\n  const result = await runAdapterExecutionTargetShellCommand(runId, target, script, {\n    cwd: target.kind === \"remote\" ? target.remoteCwd : cwd,\n    env: options.env,\n    timeoutSec: options.timeoutSec ?? 15,\n    graceSec: options.graceSec ?? 5,\n    onLog: options.onLog,\n  });\n\n  if (result.timedOut) {\n    throw new Error(`Timed out checking working directory on remote target: \"${cwd}\"`);\n  }\n  if ((result.exitCode ?? 1) !== 0) {\n    const detail = (result.stderr || result.stdout || \"\").trim();\n    if (createIfMissing) {\n      throw new Error(\n        `Could not create working directory \"${cwd}\" on remote target${detail ? `: ${detail}` : \".\"}`,\n      );\n    }\n    throw new Error(\n      `Working directory does not exist on remote target: \"${cwd}\"${detail ? ` (${detail})` : \"\"}`,\n    );\n  }\n}\n\nexport function adapterExecutionTargetSessionIdentity(\n  target: AdapterExecutionTarget | null | undefined,\n): Record<string, unknown> | null {\n  if (!target || target.kind === \"local\") return null;\n  if (target.transport === \"ssh\") return buildRemoteExecutionSessionIdentity(target.spec);\n  return {\n    transport: \"sandbox\",\n    providerKey: target.providerKey ?? null,\n    environmentId: target.environmentId ?? null,","sourceCodeStart":994,"sourceCodeEnd":1030,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/adapter-utils/src/execution-target.ts#L994-L1030","documentation":"Thrown by ensureAdapterExecutionTargetDirectory when createIfMissing is true and the `mkdir -p <cwd> && [ -d <cwd> ]` command exits non-zero on a remote target. This means the directory creation itself failed — the system attempted to create it but could not.","triggerScenarios":"Calling ensureAdapterExecutionTargetDirectory(runId, target, cwd, { createIfMissing: true, ... }) with a remote target; the mkdir command returned a non-zero exit code (not a timeout).","commonSituations":"The parent path is on a read-only filesystem; permission denied creating directories under the given path; the path contains invalid characters or resolves to a file rather than a directory; disk full on the remote; the sandbox filesystem quota is exceeded.","solutions":["Check the detail string (appended stderr/stdout) for the specific OS error message.","Verify the user/lease has write permissions on the parent directory of cwd.","Ensure the remote filesystem is not read-only or quota-limited.","Confirm the path does not conflict with an existing file at the same location."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await ensureAdapterExecutionTargetDirectory(runId, target, cwd, { createIfMissing: true });\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"Could not create working directory\")) {\n    // Inspect the detail in err.message for the OS-level reason\n    throw new Error(`Failed to create remote workspace dir: ${err.message}`);\n  }\n  throw err;\n}","preventionTips":["Verify the remote user/lease has write permissions on the target directory's parent.","Ensure the remote filesystem is not read-only or at quota.","Test directory creation interactively on the remote host before automating."],"tags":["filesystem","remote","execution-target","adapter-utils"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}