zed-industries/zed · error · anyhow::Error
git.worktree_directory must not be empty
Error message
git.worktree_directory must not be empty
What it means
The same worktree-directory validator rejects an empty value (crates/project/src/git_store.rs:10498). git.worktree_directory must be a non-empty relative path; an empty string gives Zed nothing to join onto the repository anchor and is refused before any worktree is created.
Solutions
- Remove the git.worktree_directory key from settings.json to get the default
- Set an explicit non-empty relative path such as ".zed-worktrees" or "../worktrees"
Example fix
// settings.json - before
{ "git": { "worktree_directory": "" } }
// settings.json - after
{ "git": { "worktree_directory": ".zed-worktrees" } } Defensive patterns
Strategy: validation
Validate before calling
if worktree_directory_setting.is_empty() {
return Err("git.worktree_directory must not be empty".into());
} Prevention
- Omit the key entirely to use the default instead of setting an empty string
- Lint settings files for empty-string values on path keys
When it happens
Trigger: Setting "git": { "worktree_directory": "" } in settings.json and creating a worktree. Note that "///" does not reach this check - it is caught earlier as an absolute path.
Common situations: Explicitly blanking the setting hoping to restore the default; settings templating that renders an empty value; user error.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- git.worktree_directory must be a relative path, got
- git.worktree_directory must not be ".." (use "../some-name"…
- git.worktree_directory resolved to
- A worktree already exists at
- auto_compact threshold of 0 is not valid
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20).
Data as JSON: /api/errors/a01c8e5185e3e479.
Report an issue: GitHub.
Appendix: source
Thrown at crates/project/src/git_store.rs:10516
.map(|(repo_path, _)| repo_path.clone())
.collect::<BTreeSet<_>>();
for path in &changed_paths {
let mut cursor = prev_statuses.cursor::<PathProgress>(());
cursor.seek_forward(&PathTarget::Path(path), Bias::Left);
while let Some(entry) = cursor.item() {
if !entry.repo_path.starts_with(path) {
break;
}
if !current_status_paths.contains(&entry.repo_path) {
changed_path_statuses.push(Edit::Remove(PathKey(
entry.repo_path.as_ref().clone(),
)));
}
cursor.next();
}
}
let mut cursor = prev_statuses.cursor::<PathProgress>(());
for (repo_path, status) in &*statuses.entries {
let current_diff_stat = diff_stats.get(repo_path).copied();
let current_staged_diff_stat =
staged_diff_stats.get(repo_path).copied();
let current_unstaged_diff_stat =
unstaged_diff_stats.get(repo_path).copied();
if cursor.seek_forward(&PathTarget::Path(repo_path), Bias::Left)
&& cursor.item().is_some_and(|entry| {
entry.status == *status
&& entry.diff_stat == current_diff_stat
&& entry.staged_diff_stat == current_staged_diff_stat
&& entry.unstaged_diff_stat == current_unstaged_diff_stat
})
{View on GitHub (pinned to 916fc2b8cb)