zed-industries/zed · error
buffer doesn't have a file
Error message
buffer doesn't have a file
What it means
save_buffer was called on a buffer whose file is not a local File (unsaved/new buffer, or a remote-only file), so File::from_dyn returned None and there is no worktree path to save to. This is a guard against saving buffers that have no backing file.
Source
Thrown at crates/project/src/buffer_store.rs:655
for event in events {
cx.emit(event);
}
None
}
fn unloaded_ancestor_hides_path(snapshot: &worktree::Snapshot, path: &RelPath) -> bool {
path.ancestors()
.skip(1)
.find_map(|ancestor| snapshot.entry_for_path(ancestor))
.is_some_and(|entry| entry.kind == worktree::EntryKind::UnloadedDir)
}
fn save_buffer(
&self,
buffer: Entity<Buffer>,
cx: &mut Context<BufferStore>,
) -> Task<Result<()>> {
let Some(file) = File::from_dyn(buffer.read(cx).file()) else {
return Task::ready(Err(anyhow!("buffer doesn't have a file")));
};
let worktree = file.worktree.clone();
self.save_local_buffer(buffer, worktree, file.path.clone(), false, cx)
}
fn save_buffer_as(
&self,
buffer: Entity<Buffer>,
path: ProjectPath,
cx: &mut Context<BufferStore>,
) -> Task<Result<()>> {
let Some(worktree) = self
.worktree_store
.read(cx)
.worktree_for_id(path.worktree_id, cx)View on GitHub (pinned to 9d272b0363)
Solutions
- Use save_buffer_as with an explicit target path for unsaved buffers
- Trace callers to ensure they only attempt saves on file-backed buffers
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/project/src/buffer_store.rs:655 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/6c14e20e0ad975dd.
Report an issue: GitHub.