claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Multi-user permission conflicts with /tmp/claude-*-cwd files

Open ihanikos opened this issue 2 months ago • 1 comments

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:

  1. Namespace temp files by UID (e.g., /tmp/claude-$UID-$ID-cwd or use a per-user directory like /tmp/claude-$UID/)
  2. Only access its own session's file, not iterate over all matching files
  3. Use $TMPDIR or $XDG_RUNTIME_DIR which 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

  1. Have two different user accounts on the same Linux server
  2. User A runs Claude Code, which creates /tmp/claude-XXXX-cwd files
  3. User B runs Claude Code
  4. 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.

ihanikos avatar Dec 03 '25 04:12 ihanikos

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.

github-actions[bot] avatar Jan 02 '26 10:01 github-actions[bot]

I got this issue on multi-user Mac yesterday.

codeclown avatar Jan 13 '26 07:01 codeclown

I started to experience this as well, but with the same user in both Claude Code sessions

hectortosa avatar Jan 13 '26 20:01 hectortosa

bump, experienced this, needed to rm /tmp/claude dir

jpthor avatar Jan 14 '26 06:01 jpthor

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

Osgood001 avatar Jan 21 '26 03:01 Osgood001

Same issue working on a multi-user HPC.

lizhangmai avatar Jan 28 '26 06:01 lizhangmai

I got this resolution from Claude team, add to your .zshrc or equivalent:

export CLAUDE_CODE_TMPDIR="$TMPDIR"

codeclown avatar Jan 28 '26 09:01 codeclown