Local sandbox blocks `git submodule update`, even as a no-op (worked in 1.0.99-2)

未關閉
#5,593 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
55/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
git, github, macos, zsh

研究方向

Start by tracing how local sandbox policy builds read-only paths for .git metadata, including submodules and linked worktrees, and compare those paths with the documented filesystem permissions. The issue provides a reproduction, an effective policy excerpt, and links to the two documentation pages. Done when either the no-op git submodule update works in the sandbox or the docs clearly describe the read-only paths and their effects.

由索引模型根據 Issue 內容生成。

描述

area:permissions
Describe the bug

With local sandboxing on, git submodule update cannot run in a repository that has initialized submodules, even when every submodule is already at its recorded commit. Any install or build script that calls it fails, so the agent cannot build such a repository inside the sandbox.

This is a change in behavior: 1.0.99-2 runs the same command in the same repository with sandboxing on. I found no changelog entry for it.

The failure:

error: could not write config file <repo>/.git/modules/<submodule>/config: Operation not permitted
fatal: could not set 'core.worktree' to '../../../<submodule>'

Two things combine:

  • The effective sandbox policy lists every Git config file and hooks directory under <repo>/.git as read-only, including those of each submodule (.git/modules/<submodule>/config) and of each linked worktree.
  • git submodule update rewrites core.worktree in each submodule's config on every run, whenever the key is already set, so it needs that write even when it has nothing to update. See ensure_core_worktree; Git's master has the same code.

The documentation does not mention this protection, and says the opposite:

Affected version

1.0.117-3. Not affected: 1.0.99-2. Also seen in a VS Code 1.148.0 Agents-window session.

Steps to reproduce the behavior
  1. Open a repository that has at least one initialized submodule, with local sandboxing enabled.
  2. Ask Copilot to run git submodule update --init.
  3. The command exits 128 with the error above, although git submodule status shows every submodule at its recorded commit. With sandboxing off, or on 1.0.99-2 with it on, the same command exits 0.

Seen in open-telemetry/opentelemetry.io (ten submodules), where the install, build and test scripts all run git submodule update --init first.

Excerpt of the effective sandbox policy for that repository, from the VS Code session, paths shortened:

## Working directory

### Read-only paths (153)

- <repo>/.git/config
- <repo>/.git/hooks
- <repo>/.git/modules/<submodule>/config
- <repo>/.git/modules/<submodule>/hooks
- <repo>/.git/worktrees/<worktree>/commondir
- <repo>/.git/worktrees/<worktree>/modules/<submodule>/config
- <repo>/.git/worktrees/<worktree>/modules/<submodule>/hooks
- <repo>/<submodule>/.git

### Read-write paths (1)

- <repo>
Expected behavior

One of:

  • git submodule update works inside the sandbox, at least when it has nothing to update, as it did in 1.0.99-2.
  • The documentation says that Git config files and hook directories under .git stay read-only, those of submodules and linked worktrees included, and what that means for commands that write them.
Additional context
  • macOS 27.2.1 (26B131), Apple silicon, zsh
  • git 2.54.0 (Apple Git-157)
  • From the same policy report: sandbox bypass allowed; MCP servers, LSP servers and extensions sandboxed
  • No bypass prompt was offered when the command failed, although "Allow sandbox bypass" is on
  • Asked about the failure, the CLI agent said its sandbox guidance marks .git/config, .git/hooks and the configured hooks directory as read-only inside the working directory; it does not name the configs of submodules or linked worktrees, and the user documentation mentions none of these
  • Git's side reproduces without Copilot: with a submodule's config file made immutable (chflags uchg), git submodule update --init prints the same two lines in a scratch repository
  • Workaround in use: read git submodule status, skip the update when every submodule is in sync, and run the update outside the sandbox when a recorded commit has moved
主要語言
Python
星號
11.5k
分支
2k
平均合併
6 小時 34 分鐘
30 天內合併 PR
3

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

github/copilot-cli 的其他 Issue

查看 github/copilot-cli 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。