zed-industries/zed · error · anyhow::Error
Failed to checkout files:\n{}
Error message
Failed to checkout files:\n{} What it means
The 'git checkout <commit> -- <paths>' subprocess used to restore specific files exited non-zero; git's stderr is embedded in the message. Common causes: the requested paths no longer exist in that commit, pathspec matched nothing, or the worktree/index is locked — the file restore could not be performed.
Source
Thrown at crates/git/src/repository.rs:1542
for object in objects.iter().flatten() {
if object.kind == CommitDiffObjectKind::Blob {
stdin.write_all(object.oid.as_bytes()).await?;
stdin.write_all(b"\n").await?;
has_blobs = true;
}
}
if has_blobs {
stdin.flush().await?;
}
let [new_object, old_object] = objects;
let new_object =
load_commit_object(new_object, &mut stdout, &mut info_line, &mut newline)
.await?;
let old_object =
load_commit_object(old_object, &mut stdout, &mut info_line, &mut newline)
.await?;
let is_binary = new_object.as_ref().is_some_and(|object| object.is_binary)
|| old_object.as_ref().is_some_and(|object| object.is_binary);
let new_content = new_object.map(|object| object.content);
let old_content = old_object.map(|object| object.content);
files.push(CommitFile {
path: RepoPath(Arc::from(rel_path)),
old_content,
new_content,
is_binary,
})
}
Ok(CommitDiff {
files,
is_shallow_boundary: false,
})
})
.boxed()View on GitHub (pinned to 5a9b9558db)
Solutions
- Check the embedded stderr: 'pathspec did not match' means the file is absent in the target commit — filter such paths first
- Retry when the failure is index.lock contention from a concurrent git process
- Verify the paths' RepoPath spellings match the commit's tree entries
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/git/src/repository.rs:1531 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-08-20).
Data as JSON: /api/errors/9a60723ed7f08e2a.
Report an issue: GitHub.