{"record":{"id":"ef8893cf95ee9df4","repo":"zed-industries/zed","slug":"failed-to-fetch-revision-rev-in-directory-directory","errorCode":null,"errorMessage":"failed to fetch revision {rev} in directory {directory:?}","messagePattern":"failed to fetch revision (.+?) in directory (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/extension/src/extension_builder.rs","lineNumber":392,"sourceCode":"\n        let fetch_output = util::command::new_command(\"git\")\n            .arg(\"--git-dir\")\n            .arg(&git_dir)\n            .args([\"fetch\", \"--depth\", \"1\", \"origin\", rev])\n            .output()\n            .await\n            .context(\"executing `git fetch`\")?;\n\n        let checkout_output = util::command::new_command(\"git\")\n            .arg(\"--git-dir\")\n            .arg(&git_dir)\n            .args([\"checkout\", rev])\n            .current_dir(directory)\n            .output()\n            .await\n            .context(\"executing `git checkout`\")?;\n        if !checkout_output.status.success() {\n            anyhow::ensure!(\n                fetch_output.status.success(),\n                \"failed to fetch revision {rev} in directory {directory:?}\"\n            );\n            anyhow::bail!(\n                \"failed to checkout revision {rev} in directory {directory:?}: {}\",\n                String::from_utf8_lossy(&checkout_output.stderr)\n            );\n        }\n\n        Ok(())\n    }\n\n    async fn install_rust_wasm_target_if_needed(&self) -> Result<()> {\n        let rustc_output = util::command::new_command(\"rustc\")\n            .args([\"--print\", \"target-libdir\", \"--target\", RUST_TARGET])\n            .output()\n            .await\n            .context(\"running rustc\")?;","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/extension/src/extension_builder.rs#L374-L410","documentation":"Raised in `checkout_repo` (crates/extension/src/extension_builder.rs:392) when `git checkout <rev>` fails and, while diagnosing that failure, the earlier shallow `git fetch --depth 1 origin <rev>` is found to have also failed. It means the builder could not download the requested revision of the grammar repository, so no checkout is possible. The checkout failure triggered the check, but the reported root cause is the failed fetch.","triggerScenarios":"Calling `compile_grammar` -> `checkout_repo` where `git checkout <rev>` exits non-zero AND `git fetch --depth 1 origin <rev>` also exited non-zero. Typical fetch failures: the `rev` (usually a tag like `v0.20.4`) does not exist upstream or is not a commit/branch/tag name; the repository URL is unreachable (network outage, proxy/firewall, DNS failure, GitHub downtime); authentication is required (private repo over ssh/https without credentials).","commonSituations":"An extension pins a grammar tag that was deleted or renamed upstream; developing an extension offline or behind a corporate proxy; the grammar repo moved and the pinned URL redirects away; rate-limiting or SSH key misconfiguration when fetching.","solutions":["Check network connectivity to the repo URL: `git ls-remote <url>` in a terminal; fix proxy/VPN/credentials as needed.","Verify the pinned `rev` exists in the grammar repository (`git ls-remote --tags <url>`) and update the extension's grammar pin (the `version` field in grammar repositories) to a tag that exists.","Delete the grammar directory to clear any half-fetched state (`rm -rf <directory>`) and rebuild.","If the repo moved, update the `repository`/URL the extension points to, or fork it and pin to your fork."],"exampleFix":"// before (grammars/tree-sitter-yaml/repository config in extension.toml or grammar pin)\n[grammars.tree-sitter-yaml]\nrepository = \"https://github.com/tree-sitter/tree-sitter-yaml\"\ncommit = \"v9.9.9\"   // tag does not exist upstream\n\n// after\n[grammars.tree-sitter-yaml]\nrepository = \"https://github.com/tree-sitter/tree-sitter-yaml\"\ncommit = \"v0.13.0\"  // an existing tag","handlingStrategy":"retry","validationCode":"// Verify the pinned revision exists and is reachable before building\nconst { execSync } = require('child_process');\nfunction checkRev(url, rev) {\n  const out = execSync(`git ls-remote ${url} ${rev}`, { encoding: 'utf8' });\n  if (!out.trim()) throw new Error(`revision ${rev} not found in ${url}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await buildExtension(path);\n} catch (err) {\n  if (String(err).includes(\"failed to fetch revision\")) {\n    console.error(\"Network or bad rev pin. Check connectivity and that the tag exists upstream.\", err.message);\n  }\n  throw err;\n}","preventionTips":["Pin grammar revisions to tags/commits that actually exist upstream (`git ls-remote --tags <url>` before bumping).","Configure proxy/credentials for corporate networks before building.","Retry transient network failures; the fetch is shallow but still needs connectivity.","Keep a mirror/fork of critical grammar repos to survive upstream deletions or moves."],"tags":["git","network","build","fetch"],"backgroundTag":"git-command-failed","analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-09-12T19:35:53.743Z","contentChangedAt":"2026-09-12T19:35:53.743Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}