Bash tool: heredoc fails with 'can't create temp file for here document'
Resolved 💬 2 comments Opened Mar 25, 2026 by nbros Closed Apr 23, 2026
Bug description
The Bash tool cannot execute heredocs. Any command using a here document fails with:
(eval):1: can't create temp file for here document: no such file or directory
This is notable because the system prompt explicitly instructs Claude to use heredocs for git commit messages:
ALWAYS pass the commit message via a HEREDOC
Steps to reproduce
Run any heredoc via the Bash tool:
cat <<'EOF'
hello world
EOF
Or the recommended commit pattern from the system prompt:
git commit -m "$(cat <<'EOF'
My commit message
EOF
)"
Both fail with the same error.
Expected behavior
Heredocs should work as in a normal shell session. The $TMPDIR directory exists and is writable:
TMPDIR=/var/folders/97/…/T/
drwx------ nicolas staff …/T/
Actual behavior
The error (eval):1: can't create temp file for here document: no such file or directory is raised. The (eval):1 prefix suggests the Bash tool passes commands through eval, which may interfere with heredoc temp file creation in zsh.
Impact
- Claude falls back to inline
-m "message"for commits, which can break with special characters or multi-line messages. - Any script or command relying on heredocs cannot be executed via the Bash tool.
Environment
- Claude Code: 2.1.81
- Shell: zsh 5.9 (arm64-apple-darwin25.0)
- macOS: 26.4 (build 25E246)
- No sandbox active
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗