github / github/app

[Bugs] `xcodebuild` fails in new worktree sessions

Open
#1,022 0 comments 0 reactions 0 assignees View on GitHub
Bugs
Dominant language
No language data
Stars
2.1k
Forks
153
PR merge metrics
No merged PRs in 30d

Description

**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 |

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.