Environment:
OS: macOS (Apple Silicon)
Node.js: Tested on v22 LTS, v24, v25 (Issue persists on all)
Tool: clawdbot (latest via npm)
Issue: When clawdbot attempts to execute any shell command (e.g., echo "test"), it immediately crashes with Error: spawn EBADF. This prevents any shell interaction.
Diagnosis & Debugging Steps:
System Health Check: Verified that child_process.spawn works correctly on this machine. A standalone test.js script spawns processes without issues. The problem is isolated to the clawdbot implementation.
Code Location: The error originates in dist/agents/bash-tools.exec.js around line 123 (spawn call).
Attempted Fixes (Unsuccessful):
Modified stdio to ['ignore', 'pipe', 'pipe'] to avoid stdin issues.
Switched to shell: true and removed manual shell arguments.
Attempted raw /bin/sh spawn.
Forced detached: false.
Observation: Despite valid spawn syntax and a working Node environment, the tool consistently fails with Bad File Descriptor (EBADF). This suggests the wrapper or the context in which exec is called is passing invalid handles or closing streams prematurely before the child spawns.
Stack Trace:
Plaintext
Error: spawn EBADF
at ChildProcess.spawn (node:internal/child_process:420:11)
at execute (file://.../bash-tools.exec.js:129:3)
at Object.execute (file://.../pi-tools.abort.js:38:26)
...
[tools] bash failed: spawn EBADF
Request: Please investigate how bash-tools.exec.js initializes the child process on macOS. The current implementation seems incompatible with local shell execution on this architecture.