Skip to content

[BUG] "operation not permitted: /tmp/claude-501/cwd-*" error on macOS in sandbox mode #21654

Description

@monsterhxw

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When executing any Bash command in Claude Code CLI with sandbox mode enabled, a permission error appears before the actual command output:

zsh:1: operation not permitted: /tmp/claude-501/cwd-dd16

The error occurs on every Bash command execution. The underlying commands still work, but the error message is always present.j

What Should Happen?

Commands should execute without permission errors. The temporary directory operations in /tmp/claude-501/ should work seamlessly.

Error Messages/Logs

$ git status
zsh:1: operation not permitted: /tmp/claude-501/cwd-99da

On branch main
Your branch is up to date with 'origin/main'.
...


> The error consistently references `/tmp/claude-501/cwd-*` with varying suffixes (dd16, 99da, 860e, etc.).

Steps to Reproduce

  1. Install Claude Code CLI (claude)
  2. Enable sandbox mode in ~/.claude/settings.json:
    {
      "sandbox": {
        "autoAllowBashIfSandboxed": true,
        "enabled": true
      }
    }
  3. Run claude to start a session
  4. Execute any Bash command, for example:
  5. Observe the error message zsh:1: operation not permitted: /tmp/claude-501/cwd-* appearing before the command output

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

2.1.21 (Claude Code)

Claude Code Version

2.1.23 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

  • Using Claude Code CLI
  • Sandbox mode enabled via ~/.claude/settings.json
  • The error appears to be related to Claude Code's internal handling of temporary working directory files in sandbox mode
  • The actual commands still execute successfully despite the error
  • This may be related to sandbox mode's interaction with /tmp directory operations on macOS
  • The issue affects all Bash command executions, not just specific commands

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corearea:toolsbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOSstaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions