openclaw/openclaw · critical · Error

Android release builds require a readable Git checkout

Error message

Android release builds require a readable Git checkout

What it means

Thrown by the pre-build git verification block when either `git rev-parse HEAD` or `git status --porcelain --untracked-files=all` against the working directory raises. Unlike error [4] (which only reads SHA), this gate also requires `git status` to succeed because the release must be reproducible from a clean tree. The release build refuses to start without a readable, inspectable checkout.

Source

Thrown at apps/android/scripts/build-release-artifacts.ts:148

    runGit?: (args: string[], cwd: string) => string;
  } = {},
): void {
  const cwd = options.rootDir ?? rootDir;
  const runGit =
    options.runGit ??
    ((args: string[], gitCwd: string) =>
      execFileSync("git", args, {
        cwd: gitCwd,
        encoding: "utf8",
        stdio: ["ignore", "pipe", "ignore"],
      }));
  let head: string;
  let status: string;
  try {
    head = normalizeFullGitCommit(runGit(["rev-parse", "HEAD"], cwd));
    status = runGit(["status", "--porcelain", "--untracked-files=all"], cwd).trim();
  } catch {
    throw new Error("Android release builds require a readable Git checkout");
  }
  if (head !== expectedCommit) {
    throw new Error(`Android release commit mismatch: metadata ${expectedCommit}, checkout ${head}`);
  }
  if (status) {
    throw new Error("Android release builds require a clean Git checkout");
  }
}

function parseArgs(argv: string[]): CliOptions {
  let artifact: CliOptions["artifact"] = "all";
  let dryRun = false;
  let verifyApk: string | undefined;

  for (let index = 0; index < argv.length; index += 1) {
    const arg = argv[index];
    switch (arg) {
      case "--artifact": {

View on GitHub (pinned to 01804a7531)

Solutions

  1. Run the whole release in one environment that has git and owns the checkout.
  2. Add the checkout owner with `git config --global --add safe.directory <path>`.
  3. Do not split metadata resolution and build verification across containers.
  4. Verify with `git -C <rootDir> rev-parse HEAD && git -C <rootDir> status --porcelain` before invoking.

Example fix

// before
sudo -u release-user bun build-release-artifacts.ts  # git refuses (dubious ownership)
// after
git config --global --add safe.directory "$PWD"
bun apps/android/scripts/build-release-artifacts.ts
Defensive patterns

Strategy: validation

Validate before calling

function assertReadableGit(rootDir: string): void {
  for (const args of [['rev-parse', 'HEAD'], ['status', '--porcelain', '--untracked-files=all']]) {
    execFileSync('git', args, { cwd: rootDir, stdio: 'ignore', encoding: 'utf8' });
  }
}

Try / catch

try {
  head = runGit(['rev-parse', 'HEAD'], cwd);
  status = runGit(['status', '--porcelain', '--untracked-files=all'], cwd);
} catch {
  throw new Error('Android release builds require a readable Git checkout');
}

Prevention

When it happens

Trigger: Running the build inside a container where git is missing at verification time even though metadata was resolved earlier; rootDir/file ownership mismatch making git refuse to read the index; a checkout that lost its .git between metadata resolution and verification.

Common situations: Cross-stage Docker builds where an earlier stage computed metadata but a later stage lacks git; permission changes (chown) that break git's safe.directory check; running as a different user than the one that cloned.

Related errors


AI-assisted analysis of openclaw/openclaw@01804a7531 (2026-08-12). Data as JSON: /api/errors/9a1b8c9dd6be6a35. Report an issue: GitHub.