zed-industries/zed · error
failed to checkout revision {rev} in directory {directory:?}
Error message
failed to checkout revision {rev} in directory {directory:?}: {} What it means
Raised in checkout_repo when `git checkout <rev>` fails after cloning a tree-sitter grammar repo. The ensure! guard fires because the checkout command returned a non-zero status, and the formatted args append the captured stderr/stdout of the failed checkout so the real git error (typically an unknown revision, a detached worktree, or a corrupt object database) is visible. The fetch status check on the next line is a secondary diagnostic: the revision may simply never have been fetched.
Source
Thrown at crates/extension/src/extension_builder.rs:397
.output()
.await
.context("executing `git fetch`")?;
let checkout_output = util::command::new_command("git")
.arg("--git-dir")
.arg(&git_dir)
.args(["checkout", rev])
.current_dir(directory)
.output()
.await
.context("executing `git checkout`")?;
if !checkout_output.status.success() {
anyhow::ensure!(
fetch_output.status.success(),
"failed to fetch revision {rev} in directory {directory:?}"
);
anyhow::bail!(
"failed to checkout revision {rev} in directory {directory:?}: {}",
String::from_utf8_lossy(&checkout_output.stderr)
);
}
Ok(())
}
async fn install_rust_wasm_target_if_needed(&self) -> Result<()> {
let rustc_output = util::command::new_command("rustc")
.args(["--print", "target-libdir", "--target", RUST_TARGET])
.output()
.await
.context("running rustc")?;
anyhow::ensure!(
rustc_output.status.success(),
"failed to retrieve the `{RUST_TARGET}` target libdir: {}",
String::from_utf8_lossy(&rustc_output.stderr)
);View on GitHub (pinned to 9d272b0363)
Solutions
- Verify the revision pinned in the extension's grammar manifest actually exists in the upstream repository (git ls-remote <url> <rev>)
- Delete the cached grammar directory so checkout_repo re-clones it from scratch, clearing a corrupt .git or a clone missing the needed refs
- Ensure git can reach the network: the fetch that precedes checkout must succeed before the revision is available
- Inspect the appended git output in the error message for the underlying cause (unknown revision, permission denied, lock file)
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at crates/extension/src/extension_builder.rs:397 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-09-12).
Data as JSON: /api/errors/d759fabba5a545b9.
Report an issue: GitHub.