[Bugs] `xcodebuild` fails in new worktree sessions
- 主要语言
- 没有语言数据
- 星标
- 2.1k
- 派生
- 153
- PR 合并指标
- 30 天内没有已合并 PR
描述
**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 |
贡献指南
调研方向
首先在新的 Desktop worktree 会话中使用 xcodebuild -resolvePackageDependencies 重现故障,然后检查环境中的 GIT_CONFIG_COUNT、GIT_CONFIG_KEY_0 和 GIT_CONFIG_VALUE_0。追踪 Desktop 代理命令环境注入这些变量的位置,并通过在不手动取消设置变量的情况下成功完成 SwiftPM 解析来验证完成情况,与 Copilot CLI 的对比保持一致。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- git, swift
- 领域
- build-system, desktop-dev, developer-experience
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100