google-gemini / google-gemini/gemini-cli

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

Open Beginner friendly
#28,928 10 comments 2 reactions 0 assignees View on GitHub
area/core effort/medium kind/bug priority/p1 status/bot-triaged
Dominant language
TypeScript
Stars
107k
Forks
14.6k
Avg merge
2d 3h
Merged PRs (30d)
45

Description

### 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_` and `GIT_CONFIG_VALUE_` 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:
```typescript
['diff.external', '']
```
2. **`packages/core/src/utils/gitUtils.ts`** (lines 44-45) in `getSafeGitEnv()`:
```typescript
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
* **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`.

Contributor guide

Open the contributing guide

Research direction

Start in packages/core/src/services/shellExecutionService.ts at the defaultGitOverrides entry, then compare the matching safe environment values in packages/core/src/utils/gitUtils.ts. Confirm the diff.external overrides are no longer injected and verify that Git commands in the execution sandbox use the built-in diff engine without the spawn error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.