[BUG] CLAUDE_CODE_SUBPROCESS_ENV_SCRUB creates empty ~/.bash_profile, ~/.zshrc, package.json, .env* etc. on the host, breaking login shells
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start from the sandbox start-up code that runs when CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is set and opens each protected path in append mode, which creates empty placeholders in $HOME and the working directory. Run the reproduction in the report with a temp HOME and cwd, then use find -empty to see what gets created. Done means no new files appear in the user's real HOME or project folder, and any placeholders are removed on exit. The maintainers have not chosen between the three options, so confirm the approach in the thread before writing a patch.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Preflight Checklist
- I have searched existing issues and this hasn't been reported yet
- This is a single bug report
- I am using the latest version of Claude Code
What's Wrong?
When CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 is set, Claude Code creates empty placeholder files and folders in the real $HOME and in the working directory at start-up, apparently as bind-mount targets for the bubblewrap subprocess sandbox. It opens each path in append mode, so any file that is missing is created empty, and it never removes them.
On a developer machine (not a throwaway CI runner) this silently breaks the user's shell. On Debian/Ubuntu, ~/.bash_profile normally does not exist, and bash login shells read ~/.profile, which sources ~/.bashrc. Once an empty ~/.bash_profile exists, bash reads that instead and skips ~/.profile entirely. Every login shell then loses the user's PATH: nvm, ~/.local/bin, and so on.
What happened to me: one local claude -p run with the variable set (an agent rehearsing a GitHub Actions workflow on the same machine) created ~/.bash_profile. Nothing visible happened until the next reboot. After it, a desktop app that reads PATH from bash -ilc couldn't find claude, codex, opencode or node, and the Claude CLI process exited with code 127. It took a long time to trace back to an empty 0-byte file created a day earlier.
The working directory is also littered with empty package.json, package-lock.json, yarn.lock, pnpm-lock.yaml, .gitmodules, .npmrc, eight .env* files and node_modules/.bin. In an empty folder that is mostly noise, but an empty package.json or lockfile makes npm/yarn/pnpm fail.
What Should Happen?
Enabling the scrub/sandbox should not modify the user's real files. Options:
- create mount points only inside the sandbox's own mount namespace or tmpfs, not on the host filesystem; or
- skip protecting paths that don't exist (a path that doesn't exist has nothing to protect; deny creating it instead); or
- at minimum, remove the placeholders it created on exit, and never create shell startup files (
.bash_profile,.bash_login,.profile,.zshrc, …), because their mere existence changes shell behaviour.
Error Messages/Logs
# no error; the symptom appears later, in other programs:
$ bash -ilc 'command -v node' # nothing: ~/.profile is no longer read
Claude Code process exited with code 127 before it started.
Steps to Reproduce
H=$(mktemp -d); W=$(mktemp -d); cd "$W"
env -i HOME="$H" PATH=/usr/bin:/bin CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 claude -p hi </dev/null
# (it can fail to authenticate; the files are created before that)
find "$H" "$W" -empty
Result with 2.1.332 (Linux, bubblewrap installed):
$HOME: .bash_profile .bash_aliases .bashrc .profile .zshrc .gitconfig .netrc .npmrc .yarnrc .yarnrc.yml .bunfig.toml
dirs: .config/gh .config/git .config/glab-cli .config/pip .pip
cwd: package.json package-lock.json yarn.lock pnpm-lock.yaml .gitmodules .npmrc .yarnrc .yarnrc.yml bunfig.toml
.env .env.local .env.development .env.development.local .env.test .env.test.local .env.production .env.production.local
dirs: .claude/agents .claude/commands node_modules/.bin
All of these are 0 bytes, and none existed before.
Claude Model
Other (not model-related)
Is this a regression?
I don't know
Claude Code Version
2.1.332 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux (Ubuntu 26.04 under WSL2)
Additional Information
Workaround for affected users: delete the 0-byte files, especially ~/.bash_profile. To make a machine immune, give ~/.bash_profile real content such as [ -f ~/.profile ] && . ~/.profile, since append-mode opening leaves existing files unchanged.
- Lingua principale
- TypeScript
- Stelle
- 157k
- Fork
- 25.1k
- Merge medio
- 20h 25m
- PR unite (30g)
- 4
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di anthropics/claude-code
-
area:tui enhancement platform:macos
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
anthropics/claude-code#112838 ·
-
area:docs area:plugins bug documentation low-priority platform:windows
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
anthropics/claude-code#112676 ·
-
area:docs area:hooks area:skills bug platform:windows
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
anthropics/claude-code#112675 ·
-
[DOCS] Private Azure DevOps plugin marketplaces work in the Claude desktop app – please documentApertaarea:docs area:plugins documentation enhancement platform:windows
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
anthropics/claude-code#112663 ·
-
area:agents bug has repro platform:macos
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
anthropics/claude-code#112605 ·
Tutte le issue di anthropics/claude-code
Issue simili
-
sumHorizontal, maxHorizontal, minHorizontal, allHorizontal, anyHorizontal, struct and argSortBy treat strings as literals instead of column namesForse già presa @tomaionescu l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pola-rs/nodejs-polars#486 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
jaegertracing/jaeger-ui#4853 ·
I maintainer di solito rispondono entro 1 giorno
-
area/plugins platform/linux reproduced type/bug version/v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
anomalyco/opencode#66970 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Add: Sports First TV (US)Apertaapproved check:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
RequirementAgent treats list -> add -> list as a tool call cycle and drops the second list call (Python)Forse già presa @chaitanya0305 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
i-am-bee/beeai-framework#2049 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno