[BUG] Sandbox: Bash cwd tracking writes to blocked /tmp/ path causing error noise on all commands
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When sandbox mode is enabled, every bash command fails with exit code 1 and error message /tmp/claude-{random}-cwd: Read-only file system, even though the actual command succeeds. This pollutes logs and makes successful test runs appear failed.
The bash integration writes cwd tracking files to /tmp/claude-{random}-cwd which is outside the sandbox-allowed /tmp/claude/ directory, causing write failures.
What Should Happen?
Bash cwd tracking files should be written to /tmp/claude/cwd-{random} (inside sandbox-allowed directory) and commands should return clean exit codes when operations succeed.
Error Messages/Logs
Error: Exit code 1
/bin/bash: line 4: /tmp/claude-a1b2-cwd: Read-only file system
[actual command output here - successful]
Steps to Reproduce
- Enable sandbox mode in settings
- Run any bash command (e.g., ls, git status, pytest)
- Observe error in output despite command succeeding
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2,0,37
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
OS: manjaro.
Terminal: konsole (zsh)
Proposed Solution:
Update bash tool integration to write cwd tracking files to ${TMPDIR}/cwd-{random} or hardcode /tmp/claude/cwd-{random} when sandbox is enabled.
One-line fix in bash tool code:
// Current: /tmp/claude-{id}-cwd
// Fixed: /tmp/claude/cwd-{id} or ${TMPDIR}/cwd-{id}
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗