Skip to content

node exec fails with misleading spawn /bin/sh ENOENT when agent workspace directory is missing #22793

Description

@lnxg33k

Summary

When exec runs on a node and the agent workspace directory does not exist on the remote machine, Node.js throws spawn /bin/sh ENOENT, misleadingly pointing at the shell binary rather than the real cause (missing cwd).

Steps to reproduce

  1. Register a new node/agent pair where the agent workspace directory (e.g. ~/.openclaw/workspace-) does not yet exist on the node machine.
  2. Trigger any exec command from the agent (e.g. whoami, ip a).
  3. Observe the error returned.

Expected behavior

Either auto-create the agent workspace directory on the node before running exec, or return a clear diagnostic error such as: "working directory /home/ahmed/.openclaw/workspace- not found on node — please create it or check your agent config."

Actual behavior

Node.js throws spawn /bin/sh ENOENT. The error message points at the shell binary, implying /bin/sh is missing from the system. In reality, /bin/sh exists and the shell is healthy — the real cause is that Node's child_process.spawn() fails when the specified cwd does not exist, and the ENOENT surfaces as a shell path error rather than a cwd-not-found error.

OpenClaw version

2026.2.19-2 (45d9b20)

Operating system

Debian Linux 6.12.63+deb13-amd64 (x64)

Install method

npm global

Logs, screenshots, and evidence

Impact and severity

  • Affected: Any agent running exec on a node where the workspace directory was never created (e.g. newly registered agent/node pairs)
  • Severity: High — completely blocks exec; no commands work at all
  • Frequency: 100% repro whenever the workspace directory is absent
  • Consequence: Hours of debugging misdirected at the shell binary (/bin/sh) instead of the real root cause (missing cwd). Workaround: manually create the workspace directory on the node.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions