[BUG] Sandbox: Bash cwd tracking writes to blocked /tmp/ path causing error noise on all commands

Status Fixed / completed
Maintainer reply None cached
Activity 4 comments · opened Nov 12, 2025 · closed Dec 6, 2025

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

  1. Enable sandbox mode in settings
  2. Run any bash command (e.g., ls, git status, pytest)
  3. 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}

View original on GitHub ↗

4 Comments

mkw · 9 months ago

I suspect it should use ${TMPDIR}/claude-{id}-cwd, which typically evalutes to /tmp/claude/claude-{id}-cwd, not simply the string /tmp/claude.

mkw · 9 months ago

This seems more than annoying when claude tries to execute a command that fails with a non-zero return code. At least sometimes, it interprets the failure as a sandboxing problem, ignoring the rest of the error with the real issue. Explicit instructions to avoid errors like this do seem to get it un-stuck, but it's still rather annoying.

ts-shu · 8 months ago

Is this actually completed? As of 2.0.61, seeing this for the standard /tmp and custom ${TMPDIR} still

● Bash(echo a hello world)
  ⎿  Error: Exit code 1
     /bin/bash: line 4: /tmp/claude-f365-cwd: Read-only file system

     a hello world
github-actions[bot] · 8 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.