You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow writable gitdir for current worktree in sandboxed workspace-write mode #14338
Add a way to make the current worktree gitdir writable while remaining in sandboxed workspace-write mode.
Today, when running under the Linux bubblewrap sandbox, .git and resolved gitdir: targets are force-mounted read-only after writable roots are applied. That means git fetch fails because Git cannot update .git/FETCH_HEAD (and related metadata), even when the worktree itself is writable.
An opt-in mechanism is needed for the current worktree, for example a config setting or CLI flag that relaxes the protected .git/gitdir carveout for that worktree only.
This is not solvable with --add-dir today, because the read-only mount for .git/gitdir is applied after the write dirs from the command line, so the read-only mount wins.
Before that change, git fetch in sandboxed workspace-write mode used to work in my setup.
Concrete failure: error: cannot open .git/FETCH_HEAD: Read-only file system.
Request: keep the default safety behavior, but add an explicit override for trusted local workflows that need Git metadata writes without switching all the way to danger-full-access or using per-command escalation.
Reacted by Wei HU, mohit, Sari Sakse Dalum, Felix Mokross, Doug Ludlow, lukts30, hktonylee, NaN, Yao Bin, Giles Weaver and 4 more
Thanks for the report! This just brings the linux sandbox behavior in line with macOS where writes to .git are not allowed. This was a missing feature on Landlock which is why it was working before.
Before #13453, the bubblewrap path was accidentally not re-applying the default .git / resolved gitdir read-only carveout after writable roots, so git metadata writes worked in workspace-write on Linux by accident. #13453 fixed bwrap to consume the split filesystem policy directly and re-apply those read-only subpaths.
Additional repro from Codex Desktop (macOS) in workspace-write mode:
Writable roots include both project root and parent (e.g. /Users/.../Development/Hero-Soccer and /Users/.../Development).
Normal file writes in repo succeed.
Any write under .git/ from agent tool calls fails (Operation not permitted / unable to create .git/index.lock).
Same machine/user can write to .git from external terminal and Codex terminal, so this appears specific to sandboxed tool execution.
Question from field use: does config support a wildcard allow-list for many repos (e.g. /Users/.../Development/*.git), or is explicit per-repo opt-in required once an override exists?
I opened a push-specific variant of this writable-gitdir problem: #21869 .
In workspace-write with network_access=true, I reproduced a case where git push updated the remote branch first, then failed updating the local remote-tracking ref under .git/refs/remotes/origin/* because the sandbox made the gitdir read-only. The command printed the lockfile error but exited 0.
The resulting state is worse than ordinary .git/index.lock failures:
remote branch equals local HEAD
local origin/<branch> remains stale
git status still says [ahead 1]
git fetch cannot repair because .git/FETCH_HEAD is also read-only
So the fix here is not only “Git cannot write .git”; it is also that Codex should not let/interpret a remote side effect as a failed local-only Git operation. At minimum, after this push-specific failure, Codex should verify with git ls-remote and report “remote push succeeded; local tracking ref is stale” rather than debugging auth/permissions/branch state or retrying blindly.
I ran into the same safety/autonomy tradeoff: I wanted to keep Codex in a safer workspace-write posture, but normal local Git operations need writes under .git, so the options become either repeated approvals/manual Git or relaxing the sandbox much more than I wanted.
I built a small local MCP server as a workaround: codex-safe-git.
It does not make .git broadly writable and it does not expose arbitrary shell/Git access. Instead it gives Codex a narrow, auditable Git tool surface for things like status, diff summaries, branch preparation, and exact-file commits. Remote operations are intentionally out of scope.
This is not a replacement for a proper upstream fix/config option, but it may be useful for people who want Codex to stay sandboxed while still letting it handle local Git workflows more autonomously.
git add and git commit require writes to the external worktree gitdir/common directory, so the agent requests sandbox escalation and unattended work stops waiting for approval.
The available configuration workaround creates an undesirable security tradeoff: adding the shared /path/to/main-repo/.git directory to writable_roots permits much more than staging and creating an ordinary commit. It also removes the filesystem boundary for refs, repository config, worktree metadata, and other Git state.
The desired capability is narrower than "make .git writable":
Allow staging explicitly selected files in the current managed worktree.
Allow creating a normal commit after inspecting the staged diff and running hooks.
Keep destructive/history-rewriting operations such as reset, rebase, forced ref updates, and hook bypass outside that capability.
Resolve the active worktree gitdir/common directory automatically, without requiring users to expose the entire shared .git directory as a generic writable root.
This matters for long-running autonomous tasks: repeated sandbox approval prompts for ordinary local staging/commit operations halt otherwise safe, scoped execution. A Git-aware mediated capability, or an operation-scoped permission for the current worktree, would preserve both autonomy and the intended safety boundary.
All paths above are placeholders; the behavior is not repository-specific.
I think, this description is too much about how it's to be done, than the real problem it's supposed to solve. For me, the main issue is being able to let agent create commits, and do some git operations while preserving sandbox boundary.
Activity
github-actions commentedon Mar 11, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
ryush00 commentedon Mar 19, 2026
seems same with #12280
viyatb-oai commentedon Mar 26, 2026
Thanks for the report! This just brings the linux sandbox behavior in line with macOS where writes to .git are not allowed. This was a missing feature on Landlock which is why it was working before.
Before #13453, the bubblewrap path was accidentally not re-applying the default .git / resolved gitdir read-only carveout after writable roots, so git metadata writes worked in workspace-write on Linux by accident. #13453 fixed bwrap to consume the split filesystem policy directly and re-apply those read-only subpaths.
jaredplumb commentedon Mar 29, 2026
Additional repro from Codex Desktop (macOS) in workspace-write mode:
/Users/.../Development/Hero-Soccerand/Users/.../Development)..git/from agent tool calls fails (Operation not permitted/ unable to create.git/index.lock)..gitfrom external terminal and Codex terminal, so this appears specific to sandboxed tool execution.Question from field use: does config support a wildcard allow-list for many repos (e.g.
/Users/.../Development/*.git), or is explicit per-repo opt-in required once an override exists?alvbd commentedon May 9, 2026
I opened a push-specific variant of this writable-gitdir problem: #21869 .
In
workspace-writewithnetwork_access=true, I reproduced a case wheregit pushupdated the remote branch first, then failed updating the local remote-tracking ref under.git/refs/remotes/origin/*because the sandbox made the gitdir read-only. The command printed the lockfile error but exited0.The resulting state is worse than ordinary
.git/index.lockfailures:HEADorigin/<branch>remains stalegit statusstill says[ahead 1]git fetchcannot repair because.git/FETCH_HEADis also read-onlySo the fix here is not only “Git cannot write
.git”; it is also that Codex should not let/interpret a remote side effect as a failed local-only Git operation. At minimum, after this push-specific failure, Codex should verify withgit ls-remoteand report “remote push succeeded; local tracking ref is stale” rather than debugging auth/permissions/branch state or retrying blindly.K1-R1 commentedon May 23, 2026
I ran into the same safety/autonomy tradeoff: I wanted to keep Codex in a safer
workspace-writeposture, but normal local Git operations need writes under.git, so the options become either repeated approvals/manual Git or relaxing the sandbox much more than I wanted.I built a small local MCP server as a workaround:
codex-safe-git.Repo: https://github.com/K1-R1/codex-safe-git
It does not make
.gitbroadly writable and it does not expose arbitrary shell/Git access. Instead it gives Codex a narrow, auditable Git tool surface for things like status, diff summaries, branch preparation, and exact-file commits. Remote operations are intentionally out of scope.Install:
This is not a replacement for a proper upstream fix/config option, but it may be useful for people who want Codex to stay sandboxed while still letting it handle local Git workflows more autonomously.
chemitaro commentedon Jul 11, 2026
Additional impact from Codex Desktop on macOS using a Codex-managed linked worktree:
workspace-write.git addandgit commitrequire writes to the external worktree gitdir/common directory, so the agent requests sandbox escalation and unattended work stops waiting for approval.The available configuration workaround creates an undesirable security tradeoff: adding the shared
/path/to/main-repo/.gitdirectory towritable_rootspermits much more than staging and creating an ordinary commit. It also removes the filesystem boundary for refs, repository config, worktree metadata, and other Git state.The desired capability is narrower than "make
.gitwritable":.gitdirectory as a generic writable root.This matters for long-running autonomous tasks: repeated sandbox approval prompts for ordinary local staging/commit operations halt otherwise safe, scoped execution. A Git-aware mediated capability, or an operation-scoped permission for the current worktree, would preserve both autonomy and the intended safety boundary.
All paths above are placeholders; the behavior is not repository-specific.
revert(codex): drop the ineffective main-checkout write grant
fix(codex): run codex workers with full access, like claude workers
codex: let a workflow make the workspace's git metadata writable for …
docs(skills): start Claude for implementation lanes (#202)
solomatov commentedon Nov 17, 2026
I think, this description is too much about how it's to be done, than the real problem it's supposed to solve. For me, the main issue is being able to let agent create commits, and do some git operations while preserving sandbox boundary.