Multi-user permission conflicts with /tmp/claude-*-cwd files
Multi-user permission conflicts with /tmp/claude-*-cwd files
What's Wrong?
On shared Linux servers with multiple users running Claude Code, permission denied errors occur when accessing /tmp/claude-*-cwd files owned by other users.
Claude Code creates files like /tmp/claude-XXXX-cwd to track the current working directory for bash sessions. The problem is that Claude Code appears to iterate through or check files matching this prefix pattern, not just its own session's file. When it encounters a file owned by another user, it fails with permission denied.
What Should Happen?
Claude Code should either:
- Namespace temp files by UID (e.g.,
/tmp/claude-$UID-$ID-cwdor use a per-user directory like/tmp/claude-$UID/) - Only access its own session's file, not iterate over all matching files
- Use
$TMPDIRor$XDG_RUNTIME_DIRwhich are typically per-user
Error Messages/Logs
permission denied: /tmp/claude-4551-cwd
(File owned by another user on the same server)
Steps to Reproduce
- Have two different user accounts on the same Linux server
- User A runs Claude Code, which creates
/tmp/claude-XXXX-cwdfiles - User B runs Claude Code
- User B gets permission denied errors when Claude Code tries to access User A's files
Environment
- Claude Code Version: 2.0.56
- Platform: Anthropic API
- Operating System: Oracle Linux (RHEL-compatible), kernel 6.8.0-1016-oracle
- Terminal/Shell: Standard terminal/zsh
Is this a regression?
I don't know - this may have always been an issue on multi-user systems.
Additional Information
Example of accumulated files from multiple users on a shared server:
-rw-rw-r-- 1 cao cao 21 Nov 30 11:57 /tmp/claude-0004-cwd
-rw-rw-r-- 1 claudecode claudecode 32 Nov 2 15:54 /tmp/claude-0019-cwd
-rw-rw-r-- 1 marko marko 32 Nov 10 19:50 /tmp/claude-0031-cwd
...
There are hundreds of these files accumulating. Note: #8856 tracks the separate issue of these files never being cleaned up.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
I got this issue on multi-user Mac yesterday.
I started to experience this as well, but with the same user in both Claude Code sessions
bump, experienced this, needed to rm /tmp/claude dir
Same issue working on a multi-user HPC. Strong impact, forcing me to work on my own PC as the workround, suggest fixting plan as mentioned in https://github.com/anthropics/claude-code/issues/18679
Same issue working on a multi-user HPC.
I got this resolution from Claude team, add to your .zshrc or equivalent:
export CLAUDE_CODE_TMPDIR="$TMPDIR"