zed-industries/zed · error

buffer has no file

Error message

buffer has no file

What it means

get_permalink_to_line requires a file-backed buffer, but File::from_dyn on the buffer's file returned None (untitled buffer or non-local file), so there is no repository path from which to build a permalink.

Source

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

                            project_id: project_id.to_proto(),
                            buffer_id: buffer_id.into(),
                            version: serialize_version(&version),
                        })
                        .await?;
                    Ok(deserialize_blame_buffer_response(response))
                }
            }
        })
    }

    pub fn get_permalink_to_line(
        &self,
        buffer: &Entity<Buffer>,
        selection: Range<u32>,
        cx: &mut App,
    ) -> Task<Result<url::Url>> {
        let Some(file) = File::from_dyn(buffer.read(cx).file()) else {
            return Task::ready(Err(anyhow!("buffer has no file")));
        };

        let Some((repo, repo_path)) = self.repository_and_path_for_project_path(
            &(file.worktree.read(cx).id(), file.path.clone()).into(),
            cx,
        ) else {
            // If we're not in a Git repo, check whether this is a Rust source
            // file in the Cargo registry (presumably opened with go-to-definition
            // from a normal Rust file). If so, we can put together a permalink
            // using crate metadata.
            if buffer
                .read(cx)
                .language()
                .is_none_or(|lang| lang.name() != "Rust")
            {
                return Task::ready(Err(anyhow!("no permalink available")));
            }
            let file_path = file.worktree.read(cx).absolutize(&file.path);

View on GitHub (pinned to f4178619ac)

Solutions

  1. Save the buffer to a file inside a git worktree and retry
  2. Disable permalink/copy-permalink UI actions for buffers without a local file
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/project/src/git_store.rs:2157 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/fee296fe7980cc9a. Report an issue: GitHub.