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

Open Beginner friendly
#30,328 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
git, typescript
Domain
cli, devtools

Research direction

Read packages/core/src/utils/gitUtils.ts and packages/core/src/services/shellExecutionService.ts, focusing on getSafeGitEnv() and defaultGitOverrides. Check how the overrides are tested and reproduce the issue with the provided environment variables and an SSH Git operation. Done means the unsafe empty command overrides are removed or safely replaced, while safe empty overrides remain, and the SSH operation no longer fails with unable to fork.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
109k
Forks
14.9k
Avg merge
1d 2h
Merged PRs (30d)
111

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google-gemini/gemini-cli

All issues in google-gemini/gemini-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.