Description Environment
Running Claude CLI via claude_agent_sdk subprocess.
Each agent sets HOME to a per-agent directory (e.g. /home/myapp/{agent-id}).
Working directory is a workspace path (e.g. /tmp/myapp-agents/{agent-id} or /home/myapp/{agent-id}/{workspace}).
Multiple concurrent agents/processes on same host.
Observed Behavior
CLI attempts to open a project log file under:
$HOME/.claude/projects/{normalized_cwd}/{session_id}.jsonl
When {normalized_cwd} includes slashified paths like -tmp-myapp-agents-{agent-id}, the CLI does not create the intermediate directory.
Results in:
Error opening file .../.claude/projects/-tmp-myapp-agents-{agent-id}/{session}.jsonl
ENOENT: no such file or directory
In parallel runs, CLI also logs:
Failed to save config with lock: Lock file is already being held
In some cases the process is OOM-killed (exit code -9) shortly after repeated lock and file write attempts.
Expected Behavior
CLI should ensure the full project log directory exists before opening/append.
File lock should either block or retry cleanly, not spam errors.
Concurrent runs shouldn’t corrupt .claude.json or thrash locks.
Minimal Repro
Launch two concurrent CLI processes with unique HOME dirs.
Set CWD to a path with slashes and hyphens (e.g. /tmp/myapp-agents/{agent-id}).
Observe ENOENT on .claude/projects/{normalized_cwd}/{session}.jsonl.
Workaround
Pre-create $HOME/.claude/{projects}/{normalized_cwd} before launching CLI.
Or change CLI to write project logs under a single flat directory.
Reactions are currently unavailable
You can’t perform that action at this time.
Environment
Observed Behavior
CLI attempts to open a project log file under:
$HOME/.claude/projects/{normalized_cwd}/{session_id}.jsonl
When {normalized_cwd} includes slashified paths like -tmp-myapp-agents-{agent-id}, the CLI does not create the intermediate directory.
Results in:
Error opening file .../.claude/projects/-tmp-myapp-agents-{agent-id}/{session}.jsonl
ENOENT: no such file or directory
In parallel runs, CLI also logs:
Failed to save config with lock: Lock file is already being held
In some cases the process is OOM-killed (exit code -9) shortly after repeated lock and file write attempts.
Expected Behavior
Minimal Repro
Workaround