Skip to content

E2BIG when launching Claude on Linux — --agents JSON exceeds 128KB per-argument kernel limit #797

@TickTockBent

Description

@TickTockBent

Description

il spin fails with spawn E2BIG on Linux when launching Claude because the total command-line arguments to claude exceed the kernel's ARG_MAX limit (2MB on Linux).

The launchClaude() function in src/utils/claude.ts passes the system prompt, MCP configs, agents JSON, and allowed tools list as CLI arguments via --append-system-prompt, --mcp-config, --agents, and --allowed-tools. When the system prompt is large (which is common with iloom's template system), the combined argument + environment size exceeds execve()'s limit.

Reproduction

  1. Set up a project with iloom on Linux
  2. Run il start <issue-number> or il spin from a worktree
  3. Observe spawn E2BIG error when Claude is launched
❌ Failed to spin up loom: Claude CLI error: Command failed with E2BIG: claude --model opus --permission-mode bypassPermissions --add-dir /path/to/worktree --add-dir /tmp --append-system-prompt <massive system prompt>...

This reproduces regardless of terminal backend (tested with tmux and direct invocation).

Root Cause

Linux execve() enforces ARG_MAX (typically 2MB) as the combined limit for arguments + environment. The system prompt alone can be very large, and combined with MCP configs, agents JSON, and tool lists, the total easily exceeds this limit.

On macOS, ARG_MAX is 1MB but the effective limit is stack_size/4 which is typically much larger (~16MB), so this issue may not manifest there.

Possible Solutions

  1. Write system prompt to a temp file: Use --append-system-prompt-file <path> (if Claude CLI supports it) instead of inline
  2. Pass large args via stdin: Pipe the configuration to Claude as JSON on stdin instead of CLI args
  3. Use environment variables: Store the system prompt in an env var (though this counts toward the same limit)
  4. Write a wrapper script: Generate a temp script with the full command and execute that

Environment

  • Linux 6.8.0-90-generic (Ubuntu)
  • iloom-cli v0.10.2
  • Node.js v22.12.0
  • ARG_MAX: 2097152

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions