EveryInc/compound-engineering-plugin · error · Error

${command} ${args.join(" ")} failed: ${detail}

Error message

${command} ${args.join(" ")} failed: ${detail}

What it means

The Codex dev tooling wraps every git invocation in `checkedRun`, which runs the command and throws this error if the exit code is non-zero, preferring stderr for the detail, then stdout, then a bare `exit code N`. It is a generic gatekeeper so any git failure during dev-script setup (resolving repo root, git dir, branch, HEAD, status) surfaces with its git output attached.

Source

Thrown at src/dev/codex-dev.ts:104

const OFFICIAL_PLUGIN_ID = "compound-engineering@compound-engineering-plugin"
const OFFICIAL_MARKETPLACE = "compound-engineering-plugin"
const OFFICIAL_REPOSITORY = "https://github.com/EveryInc/compound-engineering-plugin"

function trim(result: CommandResult): string {
  return result.stdout.trim()
}

async function checkedRun(
  runner: CommandRunner,
  command: string,
  args: string[],
  options: CommandOptions,
): Promise<CommandResult> {
  const result = await runner.run(command, args, options)
  if (result.exitCode !== 0) {
    const detail = result.stderr.trim() || result.stdout.trim() || `exit code ${result.exitCode}`
    throw new Error(`${command} ${args.join(" ")} failed: ${detail}`)
  }
  return result
}

function resolveHomePath(value: string, home: string): string {
  if (value === "~") return home
  if (value.startsWith("~/")) return path.join(home, value.slice(2))
  return path.resolve(value)
}

async function readJson(filePath: string): Promise<Record<string, unknown>> {
  try {
    return JSON.parse(await fs.readFile(filePath, "utf8")) as Record<string, unknown>
  } catch (error) {
    throw new Error(`Could not read ${filePath}: ${error instanceof Error ? error.message : String(error)}`)
  }
}

View on GitHub (pinned to c9c10f8c75)

Solutions

  1. Read the embedded git detail (stderr/stdout) — it names the failing git subcommand's cause.
  2. Confirm you are inside the intended git repository/worktree (`git rev-parse --git-dir`).
  3. For 'dubious ownership', add the repo: `git config --global --add safe.directory <path>`.
  4. If .git is corrupt, re-clone or restore the repo.
  5. Ensure git is installed and on PATH.

Example fix

// before (message: 'git rev-parse --show-toplevel failed: fatal: not a git repository')
cd /tmp && bun run codex:dev -- status
// after
cd /path/to/repo && bun run codex:dev -- status
Defensive patterns

Strategy: validation

Validate before calling

// Confirm you are in a healthy git repo before running the dev tooling
const r = Bun.spawnSync(["git", "rev-parse", "--git-dir"])
if (r.exitCode !== 0) throw new Error("Not inside a git repository; cd into the checkout first")

Try / catch

try {
  await devScript()
} catch (e) {
  if (e instanceof Error && / failed: /.test(e.message)) {
    // message carries the exact command and git stderr
    console.error(`Git step failed:\n${e.message}`)
  } else throw e
}

Prevention

When it happens

Trigger: Any `checkedRun(command, args, ...)` callee — repoRootRaw, gitDir, gitCommonDir, branchValue, head, status — failing: running outside a git repo (`git rev-parse` fails), corrupt .git directory, detached/unborn HEAD, unsafe-repository ownership error, or git missing from PATH.

Common situations: Running the dev script outside a git checkout; a worktree/submodule with unusual git dir layout; `detected dubious ownership` after copying a repo as root; corrupted or partially-deleted .git; git not installed.

Related errors


AI-assisted analysis of EveryInc/compound-engineering-plugin@c9c10f8c75 (2026-08-31). Data as JSON: /api/errors/419c93aa75db093a. Report an issue: GitHub.