[BUG] When Run with sudo files are created with root user instead of sudo user

Resolved 💬 3 comments Opened Jul 2, 2025 by Sorcecoder Closed Sep 15, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.40 (Claude Code)
  • Operating System: Ubuntu 22.04
  • Terminal: zsh

Bug Description

<!-- A clear and concise description of the bug -->
when running sudo claude all the files are created as root, not as sudo user.

Steps to Reproduce

  1. sudo claude
  2. Generate test.md containing a short description of project.
  3. ll -la test.md

Expected Behavior

<!-- What you expected to happen -->
-rw-r--r-- 1 sorcecoder sorcecoder 660 Jul 2 06:27 test.md

Actual Behavior

<!-- What actually happened -->
-rw-r--r-- 1 root root 660 Jul 2 06:27 test.md

Additional Context

<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->

!Image

View original on GitHub ↗

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