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
Codex seats in a git worktree: --add-dir <cwd>/.git (a file) breaks the bubblewrap sandbox for every command #121
For a Codex seat whose cwd is a linked git worktree, OpenRig launches Codex with --add-dir <cwd>/.git. In a linked worktree <cwd>/.git is a file (gitdir: <common>/.git/worktrees/<name>), not a directory. With Codex's bubblewrap sandbox (-s workspace-write) this makes every sandboxed command fail before it runs, so the seat falls back to approval prompts for everything, including rig whoami.
Environment
OpenRig built from source at 4fcf291 (0.5.17)
Codex CLI 0.158.0, Ubuntu 24.04, bubblewrap 0.9.0 with the bwrap-userns-restrict AppArmor profile loaded (the sandbox itself works: codex sandbox -- ls succeeds in an ordinary clone)
Seat cwd created with git worktree add
Reproduction
With the exact launch shape OpenRig uses (packages/daemon/src/adapters/codex-runtime-adapter.ts, the gitDirArg line):
bwrap: Can't mkdir parents for <worktree>/.git/.git: Not a directory
thread 'main' panicked at linux-sandbox/src/linux_run_main.rs:1271:21:
failed to inspect synthetic bubblewrap mount target <worktree>/.git/.codex: Not a directory (os error 20)
Passing the real git dirs instead works, including a sandboxed git commit in the worktree:
When <cwd>/.git is a file, resolve git -C <cwd> rev-parse --path-format=absolute --git-dir --git-common-dir and add each existing directory; keep the current argument when .git is a directory (or absent). We carry this as a local patch: a small codexGitDirArgs(cwd) helper replacing the one-line gitDirArg, with tests for an ordinary clone, a linked worktree, and an unresolvable .git file. Existing codex-runtime-adapter tests (70) still pass. Happy to open a PR if useful.
Thanks for the clear reproduction, the diagnosis and the working alternative. We confirmed the launch code on our side: it always added --add-dir <cwd>/.git, whether .git was a directory or, in a linked worktree, a file.
A fix based on your report is now merged in #126. When .git is a file, OpenRig now passes the real git directories instead, and it credits you for the report and the approach. It will ship in the next release. We haven't run your Linux bubblewrap setup end to end ourselves, so if you try it after the release, we'd be glad to hear whether sandboxed commands work in your worktree seats.
— dev-planner@v-openrig-build, on behalf of @mvschwarz
Thanks for the detailed write-up. #126 fixes this the same way: when a worktree's .git is a file, OpenRig asks git for the worktree's git directory and the common git directory (git rev-parse --git-dir --git-common-dir) and passes those instead. It shipped in 0.6.1 today.
— dev-planner@v-openrig-build, on behalf of @mvschwarz
We found a follow-up case after the linked-worktree fix in #126. Our installed OpenRig 0.6.14 handles fresh Codex launches. It omits the Git directory arguments when it resumes the same seat.
The seat is eval-codex-desk1@pbi-eval on Ubuntu. Its working directory is /home/openrig-eval/pbi/trees/eval-codex-desk1. That directory is a linked Git worktree. git rev-parse --path-format=absolute --git-dir --git-common-dir returns:
Neither Git directory was present. The sandbox remained workspace-write.
Our operator also observed this split across both rigs at 11:03 AM ET. Ten freshly launched PBI desks had four --add-dir values, including both Git directories. Resumed eval desks had only the two shared folders. A resumed desk's git add failed at .git/index.lock with Read-only file system. Fresh launches of eval desks 1 and 4 restored prompt-free Git writes. Those last three observations are operator reports; the /proc/5924 check above is our independent confirmation.
The installed codex-runtime-adapter.js resolves Git directories only when opts.resumeToken is absent. buildResumeCommand also calls resumeCore without Git directories. This appears to leave both normal resume and in-place restart without the directories that fresh launch receives.
Please extend #126's directory resolution to every managed Codex resume path. Keep the existing sandbox posture. A regression test could compare fresh and resume arguments for a linked worktree. The expected result is both real Git directories in both paths, without --add-dir <worktree>/.git.
Our temporary operator plan uses rig seat launch --fresh after a handoff. That creates a new conversation, so it is not a substitute for working resume.
Thanks, @bkmcd865, for the precise follow-up: the worktree path, the git rev-parse output, the resumed process's two --add-dir values, and the comparison with freshly launched agents on both rigs. As you describe it, a fresh Codex launch in a linked worktree gets both Git directories, while a resume of the same agent doesn't. It's with the team now, and we'll come back here.
Coming back on this as promised, @bkmcd865: a fix for the Codex resume path, #2023, shipped in 0.7.2, which is later than the 0.6.14 you're running. In 0.7.6, both a resume and an in-place restart pass the resolved Git directories when the agent runs on the workspace-write sandbox, as yours does, so it may already cover this. We've read that in the source; we haven't run your case. Could you retest on 0.7.6? If it still happens there, a new issue with the same detail would be welcome, and we'll take it from there.
@mvschwarz, thank you for taking the time to investigate our report. Your clear explanation of the 0.7.2 fix and 0.7.6 behavior helped us plan the upgrade and test. We appreciate your help.
Activity
fix(codex): pass real git dirs, not a worktree's .git file, to --add-…
mvschwarz commentedon Sep 29, 2026
Thanks for the clear reproduction, the diagnosis and the working alternative. We confirmed the launch code on our side: it always added
--add-dir <cwd>/.git, whether.gitwas a directory or, in a linked worktree, a file.A fix based on your report is now merged in #126. When
.gitis a file, OpenRig now passes the real git directories instead, and it credits you for the report and the approach. It will ship in the next release. We haven't run your Linux bubblewrap setup end to end ourselves, so if you try it after the release, we'd be glad to hear whether sandboxed commands work in your worktree seats.— dev-planner@v-openrig-build, on behalf of @mvschwarz
mvschwarz commentedon Sep 29, 2026
Thanks for the detailed write-up. #126 fixes this the same way: when a worktree's
.gitis a file, OpenRig asks git for the worktree's git directory and the common git directory (git rev-parse --git-dir --git-common-dir) and passes those instead. It shipped in 0.6.1 today.— dev-planner@v-openrig-build, on behalf of @mvschwarz
mvschwarz commentedon Oct 18, 2026
An update, @mgall-ibizdigital: #126 is in OpenRig 0.6.11 (release notes: https://github.com/mvschwarz/openrig/releases/tag/v0.6.11), so we're closing this as completed. If it doesn't cover your case, say so here and we'll reopen it.
fix(codex): a resumed or forked seat keeps its git dirs writable, so …
bkmcd865 commentedon Nov 1, 2026
We found a follow-up case after the linked-worktree fix in #126. Our installed OpenRig 0.6.14 handles fresh Codex launches. It omits the Git directory arguments when it resumes the same seat.
The seat is
eval-codex-desk1@pbi-evalon Ubuntu. Its working directory is/home/openrig-eval/pbi/trees/eval-codex-desk1. That directory is a linked Git worktree.git rev-parse --path-format=absolute --git-dir --git-common-dirreturns:At 11:32 AM ET on 2026-11-01,
/proc/5924/cwdpointed to that worktree. The process command containedresumeand only these two--add-dirvalues:Neither Git directory was present. The sandbox remained
workspace-write.Our operator also observed this split across both rigs at 11:03 AM ET. Ten freshly launched PBI desks had four
--add-dirvalues, including both Git directories. Resumed eval desks had only the two shared folders. A resumed desk'sgit addfailed at.git/index.lockwithRead-only file system. Fresh launches of eval desks 1 and 4 restored prompt-free Git writes. Those last three observations are operator reports; the/proc/5924check above is our independent confirmation.The installed
codex-runtime-adapter.jsresolves Git directories only whenopts.resumeTokenis absent.buildResumeCommandalso callsresumeCorewithout Git directories. This appears to leave both normal resume and in-place restart without the directories that fresh launch receives.Please extend #126's directory resolution to every managed Codex resume path. Keep the existing sandbox posture. A regression test could compare fresh and resume arguments for a linked worktree. The expected result is both real Git directories in both paths, without
--add-dir <worktree>/.git.Our temporary operator plan uses
rig seat launch --freshafter a handoff. That creates a new conversation, so it is not a substitute for working resume.mvschwarz commentedon Nov 1, 2026
Thanks, @bkmcd865, for the precise follow-up: the worktree path, the
git rev-parseoutput, the resumed process's two--add-dirvalues, and the comparison with freshly launched agents on both rigs. As you describe it, a fresh Codex launch in a linked worktree gets both Git directories, while a resume of the same agent doesn't. It's with the team now, and we'll come back here.mvschwarz commentedon Nov 1, 2026
Coming back on this as promised, @bkmcd865: a fix for the Codex resume path, #2023, shipped in 0.7.2, which is later than the 0.6.14 you're running. In 0.7.6, both a resume and an in-place restart pass the resolved Git directories when the agent runs on the workspace-write sandbox, as yours does, so it may already cover this. We've read that in the source; we haven't run your case. Could you retest on 0.7.6? If it still happens there, a new issue with the same detail would be welcome, and we'll take it from there.
bkmcd865 commentedon Nov 1, 2026
@mvschwarz, thank you for taking the time to investigate our report. Your clear explanation of the 0.7.2 fix and 0.7.6 behavior helped us plan the upgrade and test. We appreciate your help.
fix(codex): pass real git dirs, not a worktree's .git file, to --add-…
fix(codex): a resumed or forked seat keeps its git dirs writable, so …