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.
Source
Thrown at crates/project/src/git_store.rs:10498
repository_anchor_path: &Path,
worktree_directory_setting: &str,
path_style: PathStyle,
) -> Result<PathBuf> {
// Check the original setting before trimming, since a path like "///"
// is absolute but becomes "" after stripping trailing separators.
// Also check for leading `/` or `\` explicitly, because on Windows
// `Path::is_absolute()` requires a drive letter — so `/tmp/worktrees`
// would slip through even though it's clearly not a relative path.
if path_style.is_absolute(worktree_directory_setting)
|| worktree_directory_setting.starts_with('\\')
{
anyhow::bail!(
"git.worktree_directory must be a relative path, got: {worktree_directory_setting:?}"
);
}
if worktree_directory_setting.is_empty() {
anyhow::bail!("git.worktree_directory must not be empty");
}
let trimmed = worktree_directory_setting.trim_end_matches(['/', '\\']);
if trimmed == ".." {
anyhow::bail!("git.worktree_directory must not be \"..\" (use \"../some-name\" instead)");
}
let joined = path_style.join_path(repository_anchor_path, trimmed)?;
let resolved = if path_style.is_posix() {
joined
} else {
path::normalize_path(&joined)
};
let resolved = if resolved.starts_with(repository_anchor_path) {
resolved
} else if let Some(repo_dir_name) = repository_anchor_path
.file_name()
.and_then(|name| name.to_str())View on GitHub (pinned to f4178619ac)
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: {worktr
- git.worktree_directory must not be ".." (use "../some-name"
- git.worktree_directory resolved to {resolved:?}, which is ou
- untracked files are present and will NOT be included in the
- A worktree already exists at {}
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/a01c8e5185e3e479.
Report an issue: GitHub.