Skip to content

CLI sandbox remounts Git worktree gitdir read-only despite explicit .git write permission #27418

Open

Description

@lcerman

What version of Codex CLI is running?

0.139.0

What subscription do you have?

Plus

Which model were you using?

gpt-5.5

What platform is your computer?

Linux 6.8.0-124-generic x86_64 unknown

What terminal emulator and version are you using (if applicable)?

Windows Terminal to connect to Linux host

Codex doctor report

What issue are you seeing?

When running Codex in a Git worktree, the Linux sandbox remounts the resolved worktree gitdir read-only even when the Codex permission profile explicitly grants write access to the repository .git directory.
This prevents normal Git operations such as git add and git commit.

What steps can reproduce the bug?

Repository layout:

  • project root: /home/lcerman/foo
  • worktree (and codex worspace/cwd): /home/lcerman/foo/lc_dev
  • /home/lcerman/foo/lc_dev/.git file points to: /home/lcerman/foo/.git/worktrees/lc_dev
  • common git dir for all worktrees: /home/lcerman/foo/.git

Permission config includes:

[permissions.read-all-write-workspace-full-net.filesystem]
":root" = "read"
"/home/lcerman/foo/.git" = "write"

[permissions.read-all-write-workspace-full-net.filesystem.":workspace_roots"]
"." = "write"

Run inside Codex:

git add changed-files

Actual result

fatal: Unable to create /home/lcerman/foo/.git/worktrees/lc_dev/index.lock: Read-only file system

findmnt -R /home/lcerman/foo/.git executed from sandboxed codex session shows:

/home/lcerman/foo/.git                    rw
/home/lcerman/foo/.git/worktrees/lc_dev   ro
`

### What is the expected behavior?

If an explicit write permission is granted for /home/lcerman/reqview_ai/.git, Codex should allow writes to the resolved worktree gitdir below it (including subdirectories), or provide a documented way to permit Git metadata writes for
staging/committing.

### Notes

This appears related to the protected metadata policy in:

- `codex-rs/linux-sandbox/src/bwrap.rs`
- `codex-rs/protocol/src/permissions.rs`

The source appears to detect .git pointer files, resolve gitdir: ..., and **add the resolved gitdir as a protected read-only subpath**. That is reasonable as a default, but it seems to override explicit user write permission for .git.

This basically prevents codex from being able to use git (it cannot commit the work done).

The explicit `"/home/lcerman/foo/.git" = "write"` shall prevent the read-only protection enforced on .git dirs.


### Additional information

_No response_

Activity

  1. added
    CLIIssues related to the Codex CLI
    sandboxIssues related to permissions or sandboxing
    on Jun 10, 2026
  2. github-actions commented on Jun 10, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. lcerman commented on Jun 10, 2026

    @lcerman
    Author

    Btw. even when I tried to set :root = write the git is still not usable. bwrap: Can't mkdir /.git: Permission denied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIbugSomething isn't workingsandboxIssues related to permissions or sandboxing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions