Fix pages / Codex CLI

Codex CLI: "Not inside a trusted directory and --skip-git-repo-check was not specified."

Reading additional input from stdin...
Not inside a trusted directory and --skip-git-repo-check was not specified.

Tool: OpenAI Codex CLI (codex). Versions: Affected: all versions we ran (0.129.0 to 0.160.1); we reproduced it on 0.129.0, 0.160.1. Exit code 1.

Cause: codex exec exits with status 1 when neither the working directory nor any parent directory contains a .git entry, unless --skip-git-repo-check or --dangerously-bypass-approvals-and-sandbox is passed.

Fix: Run codex exec inside a Git repository (any subdirectory works), run git init first, or add --skip-git-repo-check.

# 1. inside a repository, or make the directory one
git init -q && codex exec "<prompt>"

# 2. or allow running outside a repository
codex exec --skip-git-repo-check "<prompt>"

Despite the word "trusted", in 0.160.1 the check only looks for a .git entry in the directory or its parents (get_git_repo_root). Reading additional input from stdin... is printed first whenever stdin is not a terminal; pass </dev/null in scripts.

Last verified 2026-10-07 (0.129.0, 0.160.1). Page updated . Also as Markdown and JSON.

How did we reproduce the Codex CLI error?

A fresh Debian 13 VM from bin/sandbox-run (Node.js 24, root, online, no credentials for any service), destroyed after the run. Git 2.47.3 was installed with apt for the git init fix. Without an OpenAI login the model request fails after the check, so the fix is verified by the session header Codex prints before it calls the API. Run on . Failing command: cd /root/plain && codex exec "say hi" </dev/null.

Error in an empty directory (Codex CLI 0.129.0):

$ cd /root/plain-0.129.0 && codex exec "say hi" </dev/null
Reading additional input from stdin...
Not inside a trusted directory and --skip-git-repo-check was not specified.
# exit 1

Same in the latest release (Codex CLI 0.160.1):

$ cd /root/plain-0.160.1 && codex exec "say hi" </dev/null
Reading additional input from stdin...
Not inside a trusted directory and --skip-git-repo-check was not specified.
# exit 1

Fix 1 verified: --skip-git-repo-check passes the check (the run then fails on the network) (Codex CLI 0.160.1):

$ codex exec --skip-git-repo-check "say hi" </dev/null
Reading additional input from stdin...
OpenAI Codex v0.160.1
--------
workdir: /root/plain-0.160.1
[… trimmed 16 lines …]
# exit 101

Fix 2 verified: after git init the same command passes the check (Codex CLI 0.160.1):

$ git init -q && codex exec "say hi" </dev/null
Reading additional input from stdin...
OpenAI Codex v0.160.1
--------
workdir: /root/plain-0.160.1
[… trimmed 16 lines …]
# exit 101

A subdirectory of a repository also passes (Codex CLI 0.160.1):

$ cd /root/repo/sub/dir && codex exec "say hi" </dev/null
Reading additional input from stdin...
OpenAI Codex v0.160.1
--------
workdir: /root/repo/sub/dir
[… trimmed 16 lines …]
# exit 101

Why does Codex CLI print this error?

In codex-rs/exec/src/lib.rs at rust-v0.160.1 (lines 975 to 983), codex exec prints this message and calls std::process::exit(1) when --skip-git-repo-check is not set, --dangerously-bypass-approvals-and-sandbox is not set, and get_git_repo_root finds no .git entry in the working directory or its ancestors. The CLI help describes --skip-git-repo-check as "Allow running Codex outside a Git repository." (openai/codex codex-rs/exec/src/lib.rs at rust-v0.160.1)

Related Codex CLI fixes and pages

Sources

Last verified: 2026-10-07.