git fails to access tmp directory

Resolved 💬 10 comments Opened Apr 17, 2025 by steipete Closed Aug 7, 2025
💡 Likely answer: A maintainer (jonchurch, contributor) responded on this thread — see the highlighted reply below.

Is there a way to fix these? I assume this is sandboxing in effect, it makes some git operations to fail.

$ git ls-files -i --exclude-standard

    command.stdout (code: 128, duration: 0s)

    git: warning: confstr() failed with code 5: couldn't get path of DARWIN_USER_TEMP_DIR; using /tmp instead
    git: error: couldn't create cache file '/tmp/xcrun_db-Q5a5z5VJ' (errno=Operation not permitted)
    git: warning: confstr() failed with code 5: couldn't get path of DARWIN_USER_TEMP_DIR; using /tmp instead
    git: error: couldn't create cache file '/tmp/xcrun_db-EIrGD0DV' (errno=Operation not permitted)
    ... (2 more lines)

    thinking for 17s

View original on GitHub ↗

10 Comments

jonchurch contributor · 1 year ago

Related to #207

Im hoping it would be addressed by something like #378 but this is a new path, not /var/tmp...

can you install version 0.1.2504172351 ala npm i @openai/codex@0.1.2504172351 and see if it reproduces?
Well that build does have a crash, so first make sure you do

mkdir -p ~/.pyenv then run codex

if that version doesnt work, can you pass in /tmp as a writeable root to codex?
codex -w /tmp

You are correct it is sandboxing, which you can see the policies here:
https://github.com/openai/codex/blob/c40f4891d479114b433457574eca041b666571e9/codex-cli/src/utils/agent/sandbox/macos-seatbelt.ts#L17

lukemauldinks · 1 year ago

I am using codex 0.1.2505140839 on OSX and I am getting the same error even when using codex -w /tmp.
It is 100% repeatable when doing a git commit.
Is there a solution for this yet? Let me know if you need more logs or for me to try other steps.

kalifg · 1 year ago

I just installed codex yesterday and I'm having the same issue

Damecek · 1 year ago

same issue here

   git: warning: confstr() failed with code 5: couldn't get path of DARWIN_USER_TEMP_DIR; using /tmp instead
    git: error: couldn't create cache file '/tmp/xcrun_db-SjDk74mv' (errno=Operation not permitted)
    git: warning: confstr() failed with code 5: couldn't get path of DARWIN_USER_TEMP_DIR; using /tmp instead
    git: error: couldn't create cache file '/tmp/xcrun_db-y2HLPe7e' (errno=Operation not permitted)

macos 15.4.1 (24E263)

Damecek · 1 year ago

updated to v0.1.2505172129 and looks like error is gone

    $ git add src/content_scripts/modules/x/commandPallet/commandPallet.js backlog.md && git commit -m "feat(command-palette): focus input field when palette
     opens"

    command.stdout (code: 0, duration: 1.6s)

    [feature/command-mvp d0634c6] feat(command-palette): focus input field when palette opens
     3 files changed, 18 insertions(+), 1 deletion(-)
     create mode 100644 .DS_Store
lukemauldinks · 1 year ago

I am still getting an error on the latest version when I launch codex with --approval-mode=full-auto (see the error below). But strangely enough it works as expected if I do not set the approval mode and just manually approve the command.

user
commit the change to the go.mod file to git

    command

    $ git add go.mod && git commit -m "Update go directive to v1.24.2 in go.mod"

    command.stdout (code: 128, duration: 0.1s)

    git: warning: confstr() failed with code 5: couldn't get path of DARWIN_USER_TEMP_DIR; using /tmp instead
    git: error: couldn't create cache file '/tmp/xcrun_db-MEmYhXZD' (errno=Operation not permitted)
    git: warning: confstr() failed with code 5: couldn't get path of DARWIN_USER_TEMP_DIR; using /tmp instead
    git: error: couldn't create cache file '/tmp/xcrun_db-rOPeCCsT' (errno=Operation not permitted)
    ... (7 more lines)

    command

    $ export TMPDIR=$(pwd) && git add go.mod && git commit -m "Update go directive to v1.24.2 in go.mod"

    command.stdout (code: 128, duration: 0.1s)

    error: No user exists for uid 501?

    fatal: failed to write commit object
Damecek · 1 year ago

managed to capture fail and success in single thread

  $ git add src/background/messageListener.js && git commit -m "fix(messageListener): handle unknown actions and catch errors"

    command.stdout (code: 1, duration: 71s)

    git: warning: confstr() failed with code 5: couldn't get path of DARWIN_USER_TEMP_DIR; using /tmp instead
    git: error: couldn't create cache file '/tmp/xcrun_db-bjY9w2vm' (errno=Operation not permitted)
    git: warning: confstr() failed with code 5: couldn't get path of DARWIN_USER_TEMP_DIR; using /tmp instead
    git: error: couldn't create cache file '/tmp/xcrun_db-FRcxIDMS' (errno=Operation not permitted)
    ... (17 more lines)

    command

    $ git add src/background/messageListener.js && git commit --no-verify -m "fix(messageListener): handle unknown actions and catch errors"

    command.stdout (code: 0, duration: 0.1s)

    [main 74c6789] fix(messageListener): handle unknown actions and catch errors
     1 file changed, 9 insertions(+), 1 deletion(-)

looks like when --no-verify flag is used, the error won't trigger

westito · 1 year ago

Same here. Because there is no way to disable sandbox, I solved this by clone this repo and eliminated sandbox in handle-exec-command.ts. Then installed this local package. Works like a charm.

async function getSandbox(runInSandbox: boolean): Promise<SandboxType> {
  return SandboxType.NONE;
}
Damecek · 1 year ago

this has been fixed for me, on version codex-cli 0.0.2505291458

codex-maintainers · 11 months ago

Thank you for the feedback! Please try again on the latest version of Codex CLI, as we've been addressing sandboxing and related issues. If the problem persists, feel free to reach out again.