Bash tool uses root-owned TMPDIR instead of user temp directory on macOS

Resolved 💬 3 comments Opened Feb 4, 2026 by origami1 Closed Feb 6, 2026

Description

Claude Code's Bash tool appears to use an incorrect $TMPDIR on macOS, pointing to a root-owned system temp directory instead of the user's temp directory. This causes permission denied errors on every command, though the commands themselves still execute successfully.

Environment

  • Claude Code version: 2.1.31
  • macOS version: Darwin 23.6.0
  • Shell: /bin/zsh

Observed Behavior

Every Bash command produces this error:

zsh:1: permission denied: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/claude-XXXX-cwd

The $TMPDIR inside Claude Code's shell is set to:

/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/

This directory is owned by root:wheel, but the shell is running as a regular user (uid=501).

Expected Behavior

$TMPDIR should point to the user's temp directory:

/var/folders/nv/1d4b_90j40g45q7ww65r4wwr0000gn/T/

This can be obtained via getconf DARWIN_USER_TEMP_DIR.

Impact

  • Commands report "Exit code 1" even when they succeed
  • Cosmetic/UX issue - actual functionality is not impacted
  • The error appears at zsh:1 before the actual command runs, suggesting Claude Code is prepending something that tries to write to the temp directory

Reproduction

Run any Bash command in Claude Code on macOS and observe the permission denied error in the output.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗