github / github/app

[Bugs] `xcodebuild` fails in new worktree sessions

Đang mở
#1,022 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Bugs
Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
2.1k
Fork
153
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.