mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-28 09:23:05 +08:00
fix(executor): isolate CLAUDE_CODE_TMPDIR for nested claude to fix (no output) (#154)
* fix(executor): isolate CLAUDE_CODE_TMPDIR for nested claude to fix (no output) Claude 2.1.45+ calls Nz7() in preAction to clean its tasks directory on startup. When claude runs as a nested subprocess, it deletes the parent session's *.output files, causing the parent to read an empty string and display "(no output)". Fix: assign each nested claude process its own unique CLAUDE_CODE_TMPDIR (os.TempDir()/cc-nested-<pid>-<ns>) so it only cleans its own tasks directory and never touches the parent's output files. * fix(executor): use MkdirTemp for nested tmpdir --------- Co-authored-by: cexll <evanxian9@gmail.com>
This commit is contained in:
@@ -125,6 +125,9 @@ func TestEnvInjection_LogsToStderrAndMasksKey(t *testing.T) {
|
||||
if cmd.env["ANTHROPIC_API_KEY"] != apiKey {
|
||||
t.Fatalf("ANTHROPIC_API_KEY=%q, want %q", cmd.env["ANTHROPIC_API_KEY"], apiKey)
|
||||
}
|
||||
if cmd.env["CLAUDE_CODE_TMPDIR"] == "" {
|
||||
t.Fatalf("expected CLAUDE_CODE_TMPDIR to be set for nested claude, got empty")
|
||||
}
|
||||
|
||||
if !strings.Contains(got, "Env: ANTHROPIC_BASE_URL="+baseURL) {
|
||||
t.Fatalf("stderr missing base URL env log; stderr=%q", got)
|
||||
@@ -132,4 +135,7 @@ func TestEnvInjection_LogsToStderrAndMasksKey(t *testing.T) {
|
||||
if !strings.Contains(got, "Env: ANTHROPIC_API_KEY=eyJh****test") {
|
||||
t.Fatalf("stderr missing masked API key log; stderr=%q", got)
|
||||
}
|
||||
if !strings.Contains(got, "CLAUDE_CODE_TMPDIR: ") {
|
||||
t.Fatalf("stderr missing CLAUDE_CODE_TMPDIR log; stderr=%q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user