zed-industries/zed · error

git repo must have a directory name

Error message

git repo must have a directory name

What it means

Raised while computing a directory for a new git linked worktree: the repository anchor path (main worktree path or common dir) has no final path component, so no name can be derived for the new worktree directory.

Source

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

    pub fn linked_worktree_path(&self) -> Option<&Arc<Path>> {
        self.snapshot
            .is_linked_worktree()
            .then_some(&self.work_directory_abs_path)
    }

    pub fn path_for_new_linked_worktree(
        &self,
        branch_name: &str,
        worktree_directory_setting: &str,
    ) -> Result<PathBuf> {
        let repository_anchor = self
            .snapshot
            .main_worktree_abs_path()
            .unwrap_or(self.common_dir_abs_path.as_ref());
        let project_name = repository_anchor
            .file_name()
            .and_then(|name| name.to_str())
            .ok_or_else(|| anyhow!("git repo must have a directory name"))?;
        let directory = worktrees_directory_for_repo(
            repository_anchor,
            worktree_directory_setting,
            self.path_style,
        )?;
        let directory = self.path_style.join_path(&directory, branch_name)?;
        self.path_style.join_path(&directory, project_name)
    }

    pub fn worktrees(&mut self) -> oneshot::Receiver<Result<Vec<GitWorktree>>> {
        let id = self.id;
        self.send_job("worktrees", None, move |repo, _| async move {
            match repo {
                RepositoryState::Local(LocalRepositoryState { backend, .. }) => {
                    backend.worktrees().await
                }
                RepositoryState::Remote(RemoteRepositoryState { project_id, client }) => {
                    let response = client

View on GitHub (pinned to f4178619ac)

Solutions

  1. Ensure the main worktree / common dir path is a normal absolute path with a file name
  2. Check that the git repository metadata isn't corrupted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/project/src/git_store.rs:8912 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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