paperclipai/paperclip · error · Error
Working directory does not exist on remote target: "${cwd}"$
Error message
Working directory does not exist on remote target: "${cwd}"${detail ? ` (${detail})` : ""} What it means
Thrown by ensureAdapterExecutionTargetDirectory when createIfMissing is false (the default) and the `[ -d <cwd> ]` check fails on a remote target. The directory does not exist and the caller did not ask to create it, so the operation cannot proceed.
Source
Thrown at packages/adapter-utils/src/execution-target.ts:1016
const result = await runAdapterExecutionTargetShellCommand(runId, target, script, {
cwd: target.kind === "remote" ? target.remoteCwd : cwd,
env: options.env,
timeoutSec: options.timeoutSec ?? 15,
graceSec: options.graceSec ?? 5,
onLog: options.onLog,
});
if (result.timedOut) {
throw new Error(`Timed out checking working directory on remote target: "${cwd}"`);
}
if ((result.exitCode ?? 1) !== 0) {
const detail = (result.stderr || result.stdout || "").trim();
if (createIfMissing) {
throw new Error(
`Could not create working directory "${cwd}" on remote target${detail ? `: ${detail}` : "."}`,
);
}
throw new Error(
`Working directory does not exist on remote target: "${cwd}"${detail ? ` (${detail})` : ""}`,
);
}
}
export function adapterExecutionTargetSessionIdentity(
target: AdapterExecutionTarget | null | undefined,
): Record<string, unknown> | null {
if (!target || target.kind === "local") return null;
if (target.transport === "ssh") return buildRemoteExecutionSessionIdentity(target.spec);
return {
transport: "sandbox",
providerKey: target.providerKey ?? null,
environmentId: target.environmentId ?? null,
leaseId: target.leaseId ?? null,
remoteCwd: target.remoteCwd,
};
}View on GitHub (pinned to 67001ec6eb)
Solutions
- Pass createIfMissing: true if the directory should be auto-created.
- Ensure the workspace clone/checkout step runs before calling ensureAdapterExecutionTargetDirectory.
- Verify the cwd path matches where the workspace was actually initialized on the remote.
- Check that a prior workspace restore or git sync step did not fail.
Example fix
// before
await ensureAdapterExecutionTargetDirectory(runId, target, cwd, {});
// after
await ensureAdapterExecutionTargetDirectory(runId, target, cwd, { createIfMissing: true }); Defensive patterns
Strategy: validation
Validate before calling
// Check directory existence with a probe before calling
async function remoteDirExists(runner: CommandRunner, cwd: string): Promise<boolean> {
const result = await runner.execute({
command: "sh",
args: ["-c", `[ -d ${cwd} ] && echo yes || echo no`],
cwd: "/",
timeoutMs: 10_000,
});
return result.stdout.trim() === "yes";
} Try / catch
try {
await ensureAdapterExecutionTargetDirectory(runId, target, cwd, {});
} catch (err) {
if (err instanceof Error && err.message.includes("does not exist on remote target")) {
// Retry with createIfMissing if the workspace should auto-create
await ensureAdapterExecutionTargetDirectory(runId, target, cwd, { createIfMissing: true });
} else {
throw err;
}
} Prevention
- Pass createIfMissing: true when the workspace directory may not yet exist.
- Ensure the workspace clone/checkout step runs before directory verification.
- Log workspace setup steps to diagnose missing directories.
When it happens
Trigger: Calling ensureAdapterExecutionTargetDirectory(runId, target, cwd, options) where createIfMissing is false or unset, target.kind === 'remote', and the `[ -d <cwd> ]` shell command exits non-zero.
Common situations: The workspace directory was never cloned/created on the remote; a previous workspace setup step failed silently; the lease points to a fresh filesystem where the expected repo checkout is missing; the path is wrong relative to where the workspace was actually created.
Related errors
- Could not create working directory "${cwd}" on remote target
- Working directory must be an absolute POSIX path on the remo
- Timed out checking working directory on remote target: "${cw
- Timed out checking command "${command}" on sandbox target.
- Command "${command}" is not installed or not on PATH in the
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/3a69e2acddef13bc.
Report an issue: GitHub.