paperclipai/paperclip · error
codex_startup_trust_git_resolution_failed
codex_startup_trust_git_resolution_failed
Error message
codex_startup_trust_git_resolution_failed
What it means
After computing the startup real path, the function resolves the Git repo trust root via git rev-parse --show-toplevel/--git-common-dir. If git fails AND the startup path (or an ancestor) contains a .git entry, the folder is a repository whose exact trust key could not be derived, so the function refuses to guess a different trust boundary and throws this error with the underlying cause.
Source
Thrown at packages/paperclip-runner/src/drivers/codex/codex-startup-trust.ts:85
const common = execFileSync(
"git",
[
"-C",
startup,
"rev-parse",
"--path-format=absolute",
"--git-common-dir",
],
{ encoding: "utf8", timeout: 5000, stdio: ["ignore", "pipe", "ignore"] },
).trim();
// Linked worktrees share Codex's trust key with the main checkout.
root = realpathSync(common.endsWith("/.git") ? dirname(common) : top);
} catch (error) {
// Non-Git folders have their own exact startup trust boundary. Failures
// inside a repository must not guess a different trust key.
for (let ancestor = startup; ; ancestor = dirname(ancestor)) {
if (existsSync(join(ancestor, ".git")))
throw new Error("codex_startup_trust_git_resolution_failed", {
cause: error,
});
if (dirname(ancestor) === ancestor) break;
}
}
mkdirSync(codexHome, { recursive: true, mode: 0o700 });
const path = join(codexHome, "config.toml");
const source = existsSync(path) ? readFileSync(path, "utf8") : "";
const config = parse(source);
const projects = config.projects ?? {};
if (
typeof projects !== "object" ||
Array.isArray(projects) ||
projects instanceof Date
)
throw new Error("codex_startup_trust_invalid_projects");
const project = projects[root] ?? {};
if (View on GitHub (pinned to 01ad858492)
Solutions
- Run `git -C <startup> rev-parse --show-toplevel` manually and fix the underlying git error reported in error.cause.
- Ensure the git binary is installed and on PATH inside the execution host.
- Unset interfering GIT_DIR/GIT_WORK_TREE/GIT_CEILING_DIRECTORIES in the driver environment.
- Repair or remove the broken .git entry (stale worktree gitdir) or re-clone the repository.
Example fix
// before
// inherited env breaks rev-parse
const env = {...process.env};
// after
const { GIT_DIR, GIT_WORK_TREE, GIT_CEILING_DIRECTORIES, ...cleanEnv } = process.env;
// pass cleanEnv to the driver that calls trustCodexStartupRoot Defensive patterns
Strategy: try-catch
Validate before calling
import { execFileSync } from 'node:child_process';
function gitToplevel(cwd: string): string | null { try { return execFileSync('git', ['-C', cwd, 'rev-parse', '--show-toplevel'], { stdio: ['ignore','pipe','ignore'] }).toString().trim(); } catch { return null; } } Type guard
const hasGitEntry = (dir: string): boolean => existsSync(join(dir, '.git'));
Try / catch
try { trustCodexStartupRoot(codexHome, cwd); } catch (e) { if ((e as Error).message === 'codex_startup_trust_git_resolution_failed') { console.error('git failed inside repo:', (e as Error).cause); throw new Error('Fix git environment (binary on PATH, no GIT_DIR overrides) before running Codex.', { cause: e }); } throw e; } Prevention
- Install git in execution containers and verify with `git --version` at startup
- Scrub GIT_DIR/GIT_WORK_TREE/GIT_CEILING_DIRECTORIES from the driver env
- Repair stale worktree .git files before launching runs
- Test trust setup on a plain non-git folder to isolate repo-specific git failures
When it happens
Trigger: Running inside a Git worktree/repo where git rev-parse fails: corrupted .git, GIT_DIR/GIT_CEILING_DIRECTORIES interference, git binary missing on PATH, permission problems, or a .git file pointing to a missing worktree gitdir.
Common situations: Containers without git installed, detached/checked-out worktrees with stale .git files, restricted GIT_* env vars inherited by execFileSync, deeply nested paths excluded by ceiling directories.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- codex_startup_trust_requires_absolute_paths
- [paperclip] Workspace restore preserved local working tree c
- Current checkout is the primary repo worktree. Pass --branch
- Could not read execution-target Git context
- device-login promotion: the account identifier cannot form a
AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-09-10).
Data as JSON: /api/errors/8c91ea8952606fe4.
Report an issue: GitHub.