zed-industries/zed · error
git ls-files failed in {} with status {}: {}
Error message
git ls-files failed in {} with status {}: {} What it means
Bailed when `git ls-files` executed inside a worktree exits with a non-zero status; the exit status and trimmed stderr are included in the message. The BM25 context builder runs this to enumerate tracked files, so any git-level failure — not a repository, dubious ownership, corrupted index — surfaces here before any context can be built.
Source
Thrown at crates/edit_prediction_context/src/bm25_context.rs:379
}
async fn git_ls_files(worktree_abs_path: &Path) -> Result<Vec<PathBuf>> {
let output = new_command("git")
.arg("ls-files")
.arg("-z")
.current_dir(worktree_abs_path)
.output()
.await
.with_context(|| {
format!(
"failed to run git ls-files in {}",
worktree_abs_path.display()
)
})?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
bail!(
"git ls-files failed in {} with status {}: {}",
worktree_abs_path.display(),
output.status,
stderr.trim()
);
}
let output =
String::from_utf8(output.stdout).context("git ls-files output was not valid UTF-8")?;
Ok(output
.split('\0')
.filter(|path| !path.is_empty())
.map(PathBuf::from)
.collect())
}
fn documents_for_file(
worktree_abs_path: &Path,View on GitHub (pinned to f4178619ac)
Solutions
- Run `git -C <worktree> ls-files` manually to see the underlying git error
- For dubious ownership: `git config --global --add safe.directory <worktree-path>`
- Confirm the path is a worktree: `git -C <worktree> rev-parse --is-inside-work-tree`
- Ensure git is installed and reachable from the environment the helper inherits
Defensive patterns
Strategy: validation
Validate before calling
let ok = std::process::Command::new("git")
.args(["-C", worktree.to_str().unwrap(), "rev-parse", "--is-inside-work-tree"])
.output()
.map(|o| o.status.success())
.unwrap_or(false);
if !ok { /* skip BM25 context for this worktree instead of failing */ } Try / catch
Catch the bail, log the embedded git stderr, and degrade to serving the request without BM25 file-list context rather than failing the whole context lookup.
Prevention
- Verify the worktree is a git repo before requesting BM25 context
- Configure safe.directory for repos owned by other users (CI containers)
- Ensure git is on PATH in the environment that spawns the helper
When it happens
Trigger: worktree_abs_path is not a git worktree; git refuses the repo with 'detected dubious ownership' (safe.directory); a corrupted .git/index; git not resolvable from the process environment.
Common situations: Pointing the context helper at a plain extracted directory (no .git); CI containers where the repo is owned by a different UID; spawned processes with a restricted PATH that can't find git.
Related errors
- git log failed in {} with status {}: {}
- git merge-base --is-ancestor failed
- too many arguments
- git status failed: {stderr}
- git diff-tree failed: {stderr}
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/c9447862dcae58e5.
Report an issue: GitHub.