Bug: core.sshCommand="" causes fatal: unable to fork on git push

Aperta Adatta ai principianti
#30,328 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Leggi packages/core/src/utils/gitUtils.ts e packages/core/src/services/shellExecutionService.ts, concentrandoti su getSafeGitEnv() e defaultGitOverrides. Verifica come vengono testate le sostituzioni e riproduci il problema con le variabili d’ambiente fornite e un’operazione Git tramite SSH. Il lavoro è completato quando le sostituzioni di comando vuote non sicure vengono rimosse o sostituite in modo sicuro, le sostituzioni vuote sicure vengono mantenute e l’operazione SSH non fallisce più con unable to fork.

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

Descrizione

status/need-triage

Bug Report: core.sshCommand="" causes fatal: unable to fork in Gemini CLI

Summary

Gemini CLI's getSafeGitEnv() function sets core.sshCommand (and other config keys) to empty strings via GIT_CONFIG_* environment variables. When Git attempts to use these explicitly-set-but-empty values (e.g., during an SSH push), it tries to execute an empty command, resulting in:

error: cannot run : No such file or directory
fatal: unable to fork

Root Cause

In packages/core/src/utils/gitUtils.ts, getSafeGitEnv() returns:

GIT_CONFIG_KEY_3: 'core.sshCommand',
GIT_CONFIG_VALUE_3: '',

Git treats an explicitly-set config value (even empty) as a command to execute. execvp("", ...) fails with ENOENT, which Git reports as unable to fork.

This was partially recognized in PR #29467 (which removed diff.external=""), but the other empty overrides (core.sshCommand, core.fsmonitor, core.hooksPath, core.editor, sequence.editor) were left in place.

PR #29760 added GIT_SSH_COMMAND: 'ssh -o BatchMode=yes' (which works correctly) but kept the broken core.sshCommand="" override.

Affected Code

  • packages/core/src/utils/gitUtils.ts — getSafeGitEnv() function
  • packages/core/src/services/shellExecutionService.ts — defaultGitOverrides array

Reproduction

  1. Set GIT_CONFIG_KEY_3=core.sshCommand and GIT_CONFIG_VALUE_3="" in the environment.
  2. Run git push to a remote that requires SSH.
  3. Git fails with error: cannot run : No such file or directory → fatal: unable to fork.

Proposed Fix

Remove empty string overrides for config keys that Git treats as executable commands:

  • core.sshCommand
  • core.fsmonitor
  • core.hooksPath
  • core.editor
  • sequence.editor

Only keep overrides that are safe to set empty (e.g., credential.helper="" resets the helper list without attempting execution).

Alternatively, set these to valid non-empty values that disable the feature safely (e.g., core.sshCommand='true' or omit the override entirely and rely on GIT_SSH_COMMAND env var).

Impact

All Git operations through Gemini CLI that trigger a child process fork (push, pull, fetch with SSH) fail with unable to fork when these empty config values are injected.

Lingua principale
TypeScript
Stelle
109k
Fork
14.9k
Merge medio
1g 2h
PR unite (30g)
111

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.