{"record":{"id":"eb76ce3db4d5a849","repo":"astral-sh/ruff","slug":"git-fetch-of-commit-failed","errorCode":null,"errorMessage":"Git fetch of commit {} failed: {}","messagePattern":"Git fetch of commit (.+?) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_benchmark/src/real_world_projects.rs","lineNumber":175,"sourceCode":"    let cache_dir = target_dir.join(\"benchmark_cache\").join(project_name);\n\n    if let Some(parent) = cache_dir.parent() {\n        std::fs::create_dir_all(parent).context(\"Failed to create cache directory\")?;\n    }\n\n    Ok(cache_dir)\n}\n\n/// Update an existing repository\nfn update_repository(project_root: &Path, commit: &str) -> Result<()> {\n    let output = Command::new(\"git\")\n        .args([\"fetch\", \"origin\", commit])\n        .current_dir(project_root)\n        .output()\n        .context(\"Failed to execute git fetch command\")?;\n\n    if !output.status.success() {\n        anyhow::bail!(\n            \"Git fetch of commit {} failed: {}\",\n            commit,\n            String::from_utf8_lossy(&output.stderr)\n        );\n    }\n\n    // Checkout specific commit\n    let output = Command::new(\"git\")\n        .args([\"checkout\", commit])\n        .current_dir(project_root)\n        .output()\n        .context(\"Failed to execute git checkout command\")?;\n\n    anyhow::ensure!(\n        output.status.success(),\n        \"Git checkout of commit {} failed: {}\",\n        commit,\n        String::from_utf8_lossy(&output.stderr)","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ruff_benchmark/src/real_world_projects.rs#L157-L193","documentation":"The real-world-project benchmark harness caches cloned repos; on a cache hit it runs `git fetch origin <commit>` and bails with git's stderr when the fetch exits nonzero. The embedded stderr states the actual cause.","triggerScenarios":"Running `cargo bench` real-world benchmarks with an existing cache when the fetch fails: no network, a proxy blocking git, or the pinned commit not being fetchable from origin (rewritten/deleted history).","commonSituations":"Offline or proxied CI; upstream force-push removing the pinned commit; stale caches from an older benchmark revision.","solutions":["Read the embedded git stderr first — it names the real failure (network, refspec, permissions)","Delete the project cache under target/benchmark_cache/<name> to force a fresh clone","Ensure the machine can reach the repo host over https (check proxy/firewall rules for git)","Verify the pinned commit still exists upstream (e.g. GitHub commits page for that SHA)"],"exampleFix":"# before\n bench run fails with: Git fetch of commit <sha> failed: ...\n\n# after\nrm -rf target/benchmark_cache/<project> && cargo bench --bench <real-world-bench>","handlingStrategy":"retry","validationCode":"# connectivity + commit sanity before benching\ngit ls-remote \"$repo_url\" HEAD >/dev/null 2>&1 || { echo \"repo unreachable: $repo_url\" >&2; exit 1; }\ncurl -fsS \"https://api.github.com/repos/${repo_slug}/commits/$commit\" >/dev/null || {\n  echo \"pinned commit $commit not found upstream\" >&2; exit 1;\n}","typeGuard":null,"tryCatchPattern":"match update_repository(&project_root, commit) {\n    Ok(()) => {}\n    Err(err) if err.to_string().contains(\"Git fetch\") => {\n        std::fs::remove_dir_all(&project_root)?; // drop the cache, retry with a fresh clone\n        clone_repository(repo_url, &project_root, commit)?;\n    }\n    Err(err) => return Err(err),\n}","preventionTips":["Run benchmarks on machines with unrestricted https git access","Treat target/benchmark_cache as disposable; delete it on any git failure before debugging further","Re-pin benchmark commits after upstream force-pushes"],"tags":["benchmark","git","network"],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}