[BUG] claude sometimes wants to use /tmp even though CLAUDE_CODE_TMPDIR is set in the environment
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?
I set CLAUDE_CODE_TMPDIR in the environment to a directory that exists and invoke claude --add-dir "${CLAUDE_CODE_TMPDIR}" but then sometimes claude prompts me for permission to access tmp/.
What Should Happen?
Claude should use never try to use /tmp if CLAUDE_CODE_TMPDIR is set.
My use-case is to clearly sandbox claude to a particular temporary directory without needing to manually approve access, so when claude asks for permission, it appears that either it's ignoring CLAUDE_CODE_TMPDIR _or_ that it's confused that CLAUDE_CODE_TMPDIR matches the --add-dir command-line argument.
I'm on claude-code 2.1.58, which I think is the current stable version. At least it's my intention that I'm on the stable version.
Error Messages/Logs
Steps to Reproduce
$ mkdir /tmp/blah
$ export CLAUDE_CODE_TMPDIR=/tmp/blah
$ claude --add-dir "${CLAUDE_CODE_TMPDIR}"
then, sometimes claude will request access to tmp/ instead of just automatically using /tmp/blah (in this example).
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.58
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗