Skip to content

Git command execution fails with cannot spawn : No such file or directory due to empty diff.external configuration #28928

Description

@zbynekwinkler

What happened?

When Gemini CLI runs git commands in its execution sandbox, git fails with:

cannot spawn : No such file or directory

This is because the platform attempts to override and disable external diff tools by configuring diff.external to an empty string (""). Instead of disabling external diffing, Git's diff engine treats the empty string as the name of an external executable to spawn, causing it to fail.

What did you expect to happen?

Git commands should run successfully using the built-in, standard diff engine without attempting to spawn an empty-string executable.

Client information

Client Information

0.56.0-nightly.20260806.g761f604c1
Windows (win32)

Login information

No response

Anything else we need to know?

Root Cause

The platform injects several default Git configuration overrides through GIT_CONFIG_KEY_<N> and GIT_CONFIG_VALUE_<N> environment variables. Specifically, it maps:

  • diff.external -> "" (empty string)

In Git, setting diff.external to an empty string does not disable the setting; instead, it instructs Git to spawn "" as an external diff tool, which fails with cannot spawn : No such file or directory.

Responsible Code

  1. packages/core/src/services/shellExecutionService.ts (line 520) in the defaultGitOverrides array:
    ['diff.external', '']
  2. packages/core/src/utils/gitUtils.ts (lines 44-45) in getSafeGitEnv():
    GIT_CONFIG_KEY_7: 'diff.external',
    GIT_CONFIG_VALUE_7: '',

Introducing Commit

The regression was introduced in the following commit:

  • Commit: c0d192452b4e2df7efb6d62a60385f475bfd6779
  • Author: luisfelipe-alt luisfelipe@google.com
  • Message: fix(core): normalize git environment and resolve workspace state mismatch (#28792)

Proposed Resolution

Completely remove the diff.external overrides from the default overrides list and safe environment helper, allowing Git to use its built-in engine natively. If you want to make sure no external diff tool is used, call git diff --no-ext-diff.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreIssues related to User Interface, OS Support, Core Functionalityeffort/medium2-3 days: UI state, async flow, cross-component refactorskind/bugpriority/p1Important and should be addressed in the near term.status/bot-triaged

    Type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions