github / github/app

[Bugs] `xcodebuild` fails in new worktree sessions

Abierto
#1,022 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Bugs
Lenguaje dominante
Sin datos de lenguaje
Estrellas
2.1k
Forks
153
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**Mood:** 🥲
**Category:** Bugs

**Title:** `xcodebuild` fails in new worktree sessions due to injected `GIT_CONFIG_*` (`safe.bareRepository=explicit`) breaking SwiftPM resolution

### Summary
In Copilot Desktop agent sessions running in **new git worktrees**, `xcodebuild` can fail during Swift Package resolution.

A common symptom is a misleading SwiftPM binary-target error (for whatever package is being resolved), but the underlying issue appears to be injected Git config via environment variables:

- `GIT_CONFIG_COUNT=1`
- `GIT_CONFIG_KEY_0=safe.bareRepository`
- `GIT_CONFIG_VALUE_0=explicit`

This makes Git reject SwiftPM cached bare repositories, which then cascades into package-resolution failures.

### Reproduction
1. Create/open a new worktree session in Copilot Desktop for any iOS/macOS project using SwiftPM.
2. Run:
```bash
xcodebuild -project .xcodeproj -scheme "" -resolvePackageDependencies
```
3. Observe failures such as:
```text
fatal: cannot use bare repository '.../Library/Caches/org.swift.swiftpm/repositories/...' (safe.bareRepository is 'explicit')
```
followed by secondary SwiftPM/binary-target errors.

### Expected
`xcodebuild -resolvePackageDependencies` should succeed in a fresh worktree session without requiring manual environment cleanup.

### Actual
Dependency resolution fails in Desktop agent sessions unless `GIT_CONFIG_*` overrides are removed.

### Comparison with Copilot CLI
Running the same steps in **Copilot CLI** works as expected, suggesting this is specific to **Copilot Desktop session environment setup**, not the app/project itself.

### Evidence
In failing Desktop sessions:
```bash
env | grep '^GIT_CONFIG'
# GIT_CONFIG_COUNT=1
# GIT_CONFIG_KEY_0=safe.bareRepository
# GIT_CONFIG_VALUE_0=explicit
```

When running with those vars removed, resolution succeeds:
```bash
env -u GIT_CONFIG_COUNT -u GIT_CONFIG_KEY_0 -u GIT_CONFIG_VALUE_0 xcodebuild ... -resolvePackageDependencies
```

### Workaround
Use an `xcodebuild` wrapper/shim that unsets `GIT_CONFIG_*` before delegating to `/usr/bin/xcodebuild`.

### Request
Please stop injecting this Git config into Desktop agent command environments (or scope it so SwiftPM/git operations are unaffected).

---
| Field | Value |
| --- | --- |
| App version | 0.2.32 |
| OS | macOS 26.5.1 |
| Theme | GitHub |
| Path | /chat |
| Tenure | Week 4 |

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.