can1357/oh-my-pi · error · GitCommandError
GitCommandError: git checkout --detach failed (nonzero exit)
Error message
GitCommandError: git checkout --detach failed (nonzero exit)
What it means
ensure_release_workspace() runs `git checkout --detach` in the shared clone pool so the release worktree can be cut from the default-branch commit. A nonzero exit raises GitCommandError, aborting release workspace setup before `git worktree add` runs.
Source
Thrown at python/robomp/src/sandbox.py:1056
pool = self.ensure_clone(
repo=repo,
clone_url=clone_url,
default_branch=default_branch,
refresh=False,
)
self.transport.fetch_pool(repo=repo, pool_dir=pool)
ws_root = self.workspace_root(repo, "release")
repo_dir = ws_root / "repo"
session_dir = ws_root / f".omp-session-{tag}"
context_dir = ws_root / "context"
artifacts_dir = ws_root / "artifacts"
for path in (ws_root, session_dir, context_dir, context_dir / "repro", artifacts_dir):
path.mkdir(parents=True, exist_ok=True)
detach = ["git", "checkout", "--detach"]
detached = _safe_run(detach, cwd=pool)
if detached.returncode != 0:
raise GitCommandError(detach, detached.returncode, detached.stdout, detached.stderr)
if not (repo_dir / ".git").exists():
_worktree_add(
[
"git",
"worktree",
"add",
"-B",
default_branch,
str(repo_dir),
f"origin/{default_branch}",
],
pool=pool,
repo_dir=repo_dir,
)
_share_git_metadata_with_slots(repo_dir, slot_uid)
_provision_runtime_dirs(ws_root)View on GitHub (pinned to 9690622007)
Solutions
- Inspect GitCommandError.stderr — 'index.lock exists' means remove the stale lock, 'invalid object' means the pool clone is corrupt.
- Delete the affected pool clone (under /data) and let the retry re-clone from the remote.
- Verify the upstream repo actually has a default branch with commits.
- If caused by concurrency, avoid running a second orchestrator against the same /data volume.
Defensive patterns
Strategy: retry
Validate before calling
proc = subprocess.run(['git', 'rev-parse', 'HEAD'], cwd=pool, capture_output=True)
if proc.returncode != 0:
raise RuntimeError(f'pool clone unusable: {proc.stderr.decode()}') Type guard
from robomp.sandbox import GitCommandError
def has_returncode(exc: BaseException, code: int) -> bool:
return isinstance(exc, GitCommandError) and exc.returncode == code Try / catch
try:
ws = manager.ensure_release_workspace(repo=repo, tag=tag)
except GitCommandError as e:
if e.returncode == 124:
... # timeout: check for hung git / locks before retrying
else:
... # re-clone pool and retry once Prevention
- Never run two orchestrators against the same /data volume
- Verify upstream repos have a non-empty default branch before enabling releases
- Watch for stale index.lock files after container crashes
When it happens
Trigger: Calling ensure_release_workspace() when the pool clone has no commits (empty upstream repo), is mid-rebase/merge with conflicts, has a locked index, or `git checkout --detach` hits a corrupt object database.
Common situations: First release event for a repo whose clone pool was seeded from an empty or unreachable remote; concurrent process holding the pool's index.lock; corrupted clone after a container kill.
Related errors
- GitCommandError: git command failed (nonzero exit)
- Isolated subagent execution could not be prepared: ${message
- could not find an unused worktree path under ${basePath} (tr
- git timed out after {effective_timeout:.0f}s: {' '.join(_red
- GitCommandError(cmd, proc.returncode, proc.stdout, proc.stde
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/c6f782c1f2b4ad85.
Report an issue: GitHub.