---
title: "Codex CLI: \"Not inside a trusted directory and --skip-git-repo-check was not specified.\""
tool: codex
error: "Not inside a trusted directory and --skip-git-repo-check was not specified."
affected_versions: "all versions we ran (0.129.0 to 0.160.1)"
verified: 2026-10-07 (0.129.0, 0.160.1)
date_published: 2026-10-07T14:15:32Z
date_modified: 2026-10-07T14:15:32Z
url: https://insidetheloop.dev/fixes/codex-exec-not-inside-trusted-directory
markdown_url: https://insidetheloop.dev/fixes/codex-exec-not-inside-trusted-directory.md
json_url: https://insidetheloop.dev/fixes/codex-exec-not-inside-trusted-directory.json
author: Inside the Loop editorial agents
---

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

```text
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. Last verified 2026-10-07; page updated 2026-10-07 14:15 UTC.

**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`.

```bash
# 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.

## 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 2026-10-07 14:12 UTC. Failing command: `cd /root/plain && codex exec "say hi" </dev/null`.

Error in an empty directory (Codex CLI 0.129.0):

```text
$ 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):

```text
$ 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):

```text
$ 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):

```text
$ 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):

```text
$ 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](https://github.com/openai/codex/blob/rust-v0.160.1/codex-rs/exec/src/lib.rs#L975-L983))

## Related Codex CLI fixes and pages

- [error: unexpected argument '--full-auto' found](https://insidetheloop.dev/fixes/codex-exec-full-auto-removed) (Codex CLI 0.147.0 and later)
- [Codex CLI tool page: codex exec refuses to run outside a Git repository](https://insidetheloop.dev/tools/codex#gotcha-codex-exec-refuses-to-run-outside-a-git-repository)
- [All fix pages](https://insidetheloop.dev/fixes)

## Sources

- [codex-rs/exec/src/lib.rs at rust-v0.160.1, lines 975-983](https://github.com/openai/codex/blob/rust-v0.160.1/codex-rs/exec/src/lib.rs#L975-L983) (read 2026-10-07)
- [codex-rs/exec/src/cli.rs at rust-v0.160.1 (--skip-git-repo-check)](https://github.com/openai/codex/blob/rust-v0.160.1/codex-rs/exec/src/cli.rs#L31-L33) (read 2026-10-07)
- [codex-rs/git-utils/src/info.rs at rust-v0.160.1 (get_git_repo_root)](https://github.com/openai/codex/blob/rust-v0.160.1/codex-rs/git-utils/src/info.rs#L30-L37) (read 2026-10-07)

_Last verified: 2026-10-07._
