zed-industries/zed · error · RuntimeError
origin/main tip unavailable locally after fetch
Error message
origin/main tip {main_sha[:12]} unavailable locally after fetch What it means
The on-main check resolves origin/main's tip sha via ls-remote, then fetches main into the local repo to test ancestry. If after `git fetch <repo_url> main` the resolved main sha still is not present locally, this RuntimeError fires. The fetch's output is captured and swallowed, so the real network, auth, or ref problem is hidden; the docstring frames this as 'cannot answer' rather than a definitive 'not on main'.
Solutions
- Run the fetch manually to surface the real error: git -C <repo> fetch <repo_url> main
- Fix network or credentials for the git host, then retry
- Re-resolve origin/main before retrying — if main moved, recompute main_sha with resolve_remote_ref
- If the local repo is shallow/partial, unshallow it or work from a full clone
Example fix
# before on_main = check_on_main(...) # RuntimeError: origin/main tip 0123456789ab unavailable locally after fetch # after — expose the swallowed fetch error git -C $ZED_EVAL_REPO fetch <repo_url> main # fix auth/network, then retry
Defensive patterns
Strategy: retry
Validate before calling
completed = subprocess.run(
["git", "-C", repo_root(), "fetch", repo_url, "main"], capture_output=True
)
if completed.returncode != 0:
raise RuntimeError(completed.stderr.decode(errors="replace")) # surface before the ancestry check Try / catch
try:
on_main = check_on_main(base_sha, repo_url)
except RuntimeError as err:
if "unavailable locally after fetch" in str(err):
wait_for_connectivity() # re-resolve origin/main too, in case it moved
on_main = check_on_main(base_sha, repo_url)
else:
raise Prevention
- Keep git host credentials current in CI
- When this fires, run the manual fetch command — the real error was captured and hidden
- Re-resolve origin/main before retrying to avoid sha races during active pushes
When it happens
Trigger: The machine is offline or DNS fails so the fetch silently errors; repo_url requires credentials that are missing or expired; main was force-pushed between resolve_remote_ref and fetch so the old tip is no longer served; the local clone is shallow or partial with fetch restrictions.
Common situations: CI runner without egress to the git host; expired PAT or SSH key; races during active pushes to main; corporate proxies blocking git; filtered partial clones.
Related errors
- failed to fetch revision
- could not resolve ref
- failed to send message
- git clone failed
- Timed out pinging remote client
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/d979c6ae26a94350.
Report an issue: GitHub.
Appendix: source
Thrown at crates/eval_cli/zed_eval/source.py:107
def base_sha_on_main(base_sha: str, repo_url: str) -> bool:
"""Whether `base_sha` is reachable from origin/main.
Resolves origin/main's tip against the remote (so it doesn't depend on the
caller's possibly-stale local refs), fetching main if the objects aren't
present locally, then checks ancestry. Raises only when the main tip can't be
made available locally (a network/remote problem), so callers can
distinguish that from a definitive "not on main".
"""
main_sha = resolve_remote_ref(repo_url, "main")
if base_sha.lower() == main_sha.lower():
return True
if not (commit_present(base_sha) and commit_present(main_sha)):
subprocess.run(
["git", "-C", repo_root(), "fetch", "--quiet", repo_url, "main"],
capture_output=True,
)
if not commit_present(main_sha):
raise RuntimeError(
f"origin/main tip {main_sha[:12]} unavailable locally after fetch"
)
if not commit_present(base_sha):
# Not present even after pulling main's history -> not reachable from main.
return False
ancestry = subprocess.run(
["git", "-C", repo_root(), "merge-base", "--is-ancestor", base_sha, main_sha],
capture_output=True,
)
if ancestry.returncode in (0, 1):
return ancestry.returncode == 0
raise RuntimeError(
(ancestry.stderr or b"").decode(errors="replace").strip()
or "git merge-base --is-ancestor failed"
)
def resolve_git_ref(ref: str) -> str:View on GitHub (pinned to f4178619ac)