{"record":{"id":"18df82ec5075e7c3","repo":"Hmbown/CodeWhale","slug":"ssh-ex-userhost-mkdir-failed-r-stderr-trim-slice-0-300","errorCode":null,"errorMessage":"ssh ${ex.userHost}: mkdir failed: ${r.stderr.trim().slice(0, 300)}","messagePattern":"ssh (.+?): mkdir failed: (.+?)","errorType":"exception","errorClass":"ExecError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/transport.mjs","lineNumber":283,"sourceCode":"  };\n  attachPersistentChannel(ex, binding, [\"docker\", \"exec\", \"-i\", container, \"/bin/sh\", remoteAgent, \"--serve\"]);\n  return ex;\n}\n\n/** Push the self-contained remote agent + src tree to an ssh computer. */\nexport async function installRemoteAgent(computer) {\n  const ex = sshExec(computer);\n  const srcDir = path.join(PLUGIN_ROOT, \"src\");\n  const rels = [\"agent.mjs\"];\n  for (const dir of [\"\", \"backends\"]) {\n    const full = path.join(srcDir, dir);\n    for (const f of fs.readdirSync(full)) {\n      if (f.endsWith(\".mjs\") || f.endsWith(\".m\") || f.endsWith(\".h\")) rels.push(`src/${dir ? dir + \"/\" : \"\"}${f}`);\n    }\n  }\n  const marker = \".codewhale-cu/agent\";\n  let r = await run(\"ssh\", [...ex.base, \"mkdir\", \"-p\", `${marker}/src/backends`], { timeoutMs: 15_000 });\n  if (r.code !== 0) throw new ExecError(`ssh ${ex.userHost}: mkdir failed: ${r.stderr.trim().slice(0, 300)}`, r);\n  for (const rel of rels) {\n    const localPath = rel === \"agent.mjs\" ? path.join(PLUGIN_ROOT, \"agent.mjs\") : path.join(srcDir, rel.slice(4));\n    const dest = safeRemotePath(`${marker}/${rel}`);\n    r = await run(\"scp\", [...(computer.port ? [\"-P\", String(computer.port)] : []), localPath, `${ex.userHost}:${dest}`], { timeoutMs: 30_000 });\n    if (r.code !== 0) throw new ExecError(`scp ${rel} failed: ${r.stderr.trim().slice(0, 300)}`, r);\n  }\n  // Probe remote platform via the agent itself.\n  const reply = await ex.remote({ tool: \"platform\" });\n  return { installed: rels.length, remotePlatform: reply.platform, agentPath: `${marker}/agent.mjs` };\n}\n\n/** hdc (HarmonyOS) executor. Commands run on-device; files pull to local tmp. */\nexport function hdcExec(computer) {\n  const targetArgs = computer.target ? [\"-t\", computer.target] : [];\n  const shell = (args, opts = {}) => run(\"hdc\", [...targetArgs, \"shell\", ...args], opts);\n  return {\n    kind: \"hdc\",\n    targetArgs,","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/transport.mjs#L265-L301","documentation":"installRemoteAgent() first creates the remote directory tree .codewhale-cu/agent/src/backends via `ssh mkdir -p`. If that ssh command exits nonzero it throws this ExecError embedding trimmed stderr (max 300 chars). It means the remote directory could not be created, so no agent files can be uploaded.","triggerScenarios":"Calling installRemoteAgent() when the initial `ssh ... mkdir -p` fails: connection refused, auth failure, remote shell unavailable, home directory not writable, or disk full on the remote host.","commonSituations":"SSH keys not set up; wrong host/port/user in the binding; remote account with restricted shell (e.g. nologin, rbash); quota/disk-full on the remote home; SELinux or permissions preventing mkdir in home.","solutions":["Test manually: ssh <userHost> 'mkdir -p .codewhale-cu/agent/src/backends' and read the full error","Verify SSH connectivity/auth (keys, agent forwarding, known_hosts)","Check remote home writability and disk quota","Confirm the user's shell is interactive enough to run mkdir","Read the embedded stderr in the message for the precise cause"],"exampleFix":"// before\nawait installRemoteAgent(ex, computer); // auth fails -> mkdir failed\n// after\nconst probe = await run(\"ssh\", [...ex.base, \"true\"]);\nif (probe.code !== 0) throw new Error(`ssh unreachable: ${probe.stderr}`); // diagnose first\nawait installRemoteAgent(ex, computer);","handlingStrategy":"try-catch","validationCode":"const probe = await run(\"ssh\", [...base, \"mkdir\", \"-p\", \".codewhale-cu/agent/src/backends\"]);\nif (probe.code !== 0) throw new Error(`cannot prepare remote dir: ${probe.stderr}`); // see full stderr before install","typeGuard":"function isMkdirFailure(e) { return e instanceof ExecError && e.message.includes(\"mkdir failed\"); }","tryCatchPattern":"try {\n  await installRemoteAgent(ex, computer);\n} catch (e) {\n  if (e.message.includes(\"mkdir failed\")) {\n    console.error(\"remote mkdir failed:\", e.message); // auth/shell/quota issues\n    // fix ssh access or remote permissions, then retry\n  }\n  throw e;\n}","preventionTips":["Set up ssh keys and confirm interactive ssh works before installing","Check remote home directory is writable and has free quota","Ensure the remote account's shell can execute simple commands"],"tags":["ssh","mkdir","installation"],"backgroundTag":"ssh-command-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}