store: Fix: claude -p nested session failure due to CLAUDECODE env var
This commit is contained in:
parent
313db1fb3e
commit
6e3a0ae753
@ -0,0 +1,34 @@
|
||||
---
|
||||
id: 250d2fe0-5866-42f1-b83d-187b3a64fb84
|
||||
type: fix
|
||||
title: "Fix: claude -p nested session failure due to CLAUDECODE env var"
|
||||
tags: [claude-code, headless, nested-sessions, fix, claude-scheduled, subprocess]
|
||||
importance: 0.7
|
||||
confidence: 0.8
|
||||
created: "2026-03-01T06:21:07.380774+00:00"
|
||||
updated: "2026-03-01T06:21:07.380774+00:00"
|
||||
---
|
||||
|
||||
# claude -p Nested Session Error Fix
|
||||
|
||||
## Problem
|
||||
`claude -p` fails with "cannot be launched inside another Claude Code session" when the `CLAUDECODE` environment variable is set in the calling shell.
|
||||
|
||||
## Fix
|
||||
Unset the variable before invoking:
|
||||
```bash
|
||||
unset CLAUDECODE
|
||||
claude -p ...
|
||||
```
|
||||
|
||||
In Python subprocess calls (e.g. from ai-assistant project):
|
||||
```python
|
||||
env.pop('CLAUDECODE', None)
|
||||
```
|
||||
|
||||
## Additional related gotchas
|
||||
- `--permission-mode bypassPermissions` cannot be used by root users — must run as non-root
|
||||
- `--max-budget-usd` is not an instant hard cutoff — it can overshoot (set $0.25, spent $0.37); use conservatively
|
||||
|
||||
## Context
|
||||
Discovered while building claude-scheduled task runner. Also applies to any project launching Claude Code as a subprocess.
|
||||
Loading…
Reference in New Issue
Block a user