zed-industries/zed · error · anyhow::Error

git.worktree_directory must not be ".." (use "../some-name"…

Error message

git.worktree_directory must not be ".." (use "../some-name" instead)

What it means

After trimming trailing separators, a worktree_directory value equal to exactly ".." would resolve the worktree directory to the repository's parent directory itself, colliding with the repo's own directory (crates/project/src/git_store.rs:10503). Zed rejects it and asks for a named sibling like "../some-name" instead.

Solutions

  1. Use a named sibling directory: "../my-repo-worktrees"
  2. Or keep worktrees inside the repository: ".worktrees"

Example fix

// settings.json - before
{ "git": { "worktree_directory": ".." } }

// settings.json - after
{ "git": { "worktree_directory": "../acme-worktrees" } }
Defensive patterns

Strategy: validation

Validate before calling

let trimmed = setting.trim_end_matches(['/', '\\']);
if trimmed == ".." {
    return Err("git.worktree_directory must not be \"..\" (use \"../some-name\" instead)".into());
}

Prevention

When it happens

Trigger: Setting git.worktree_directory to "..", or values that reduce to it after trimming trailing separators, such as "../" or "..\\".

Common situations: Users trying to scatter worktrees directly in the folder that contains their repos, without a naming prefix.

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


AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20). Data as JSON: /api/errors/6e06cb28cddb3c63. Report an issue: GitHub.

Appendix: source

Thrown at crates/project/src/git_store.rs:10521

                            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
                                })
                            {
                                continue;
                            }

                            changed_path_statuses.push(Edit::Insert(StatusEntry {
                                repo_path: repo_path.clone(),

View on GitHub (pinned to 916fc2b8cb)