--acp never answers initialize when a sandbox is enabled (stdin read as a piped prompt before the sandbox hop)

Aperta Adatta ai principianti
#30,398 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Raamia ci sta già lavorando.

Dal 22/11/2026.

  • #30400 di @Raamia — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
cli

Direzione di ricerca

Inizia in packages/cli/src/gemini.tsx intorno alla lettura di stdin dentro il ramo if (sandboxConfig), poi leggi packages/cli/src/utils/readStdin.ts per capire perché il timer di 1 s viene cancellato al primo chunk. Decidi come il flag ACP (--acp / --experimental-acp) è noto a quel punto e salta la lettura del prompt piped quando è impostato, così il salto nella sandbox avviene subito. Fatto significa che GEMINI_SANDBOX=sandbox-exec gemini --acp risponde a initialize subito, con i test CLI esistenti ancora superati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

status/need-triage
What happened?

With a sandbox enabled (GEMINI_SANDBOX, --sandbox, or tools.sandbox in settings), gemini --acp never answers an ACP client's initialize request when the client writes it as soon as the process starts. Without a sandbox it answers at once.

The cause: before hopping into the sandbox, the CLI reads a non-TTY stdin as a piped prompt:

https://github.com/google-gemini/gemini-cli/blob/v0.70.0/packages/cli/src/gemini.tsx#L705-L728

readStdin() clears its 1 s "nothing piped" timer at the first chunk, then waits for an end of input that an ACP stdio transport never sends. So the CLI waits forever and never starts the sandboxed process:

https://github.com/google-gemini/gemini-cli/blob/v0.70.0/packages/cli/src/utils/readStdin.ts#L35-L120

A client that holds its first write back for about 3 s does get an answer, because the timer fires first and the read ends empty, but that's a race, not a fix.

This looks like the cause of #22782 (--acp hanging, with sandbox-exec (permissive-open) in its client information), which was closed as not planned.

Steps to reproduce

  1. On macOS, start GEMINI_SANDBOX=sandbox-exec gemini --acp.
  2. Immediately write an ACP initialize request line to its stdin.
  3. No response arrives (waited 15 s). Without GEMINI_SANDBOX, the response arrives at once.
What did you expect to happen?

With a sandbox enabled, --acp hops into the sandbox and answers initialize from inside it. ACP never takes a piped prompt, so skipping the stdin read when --acp (or --experimental-acp) is set should fix it.

Client information
  • CLI version: 0.70.0 (also 0.69.0)
  • Platform: macOS (darwin arm64)
  • Sandbox: sandbox-exec (permissive-open)

The read sits inside if (sandboxConfig), before the hop, so any sandbox command should behave the same.

Login information

None needed: reproduced with a fresh GEMINI_CLI_HOME and no account configured.

Lingua principale
TypeScript
Stelle
109k
Fork
15k
Merge medio
1g 1h
PR unite (30g)
106

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di google-gemini/gemini-cli

Tutte le issue di google-gemini/gemini-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.