{"record":{"id":"bb46405e457e6b1d","repo":"zed-industries/zed","slug":"cannot-save-buffer-with-absolute-path","errorCode":null,"errorMessage":"Cannot save buffer with absolute path","messagePattern":"Cannot save buffer with absolute path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/vim/src/command.rs","lineNumber":496,"sourceCode":"            }\n            return;\n        }\n        vim.update_editor(cx, |_, editor, cx| {\n            let Some(project) = editor.project().cloned() else {\n                return;\n            };\n            let Some(worktree) = project.read(cx).visible_worktrees(cx).next() else {\n                return;\n            };\n            let path_style = worktree.read(cx).path_style();\n            let Ok(project_path) =\n                RelPath::new(Path::new(&action.filename), path_style).map(|path| ProjectPath {\n                    worktree_id: worktree.read(cx).id(),\n                    path: path.into_arc(),\n                })\n            else {\n                // TODO implement save_as with absolute path\n                Task::ready(Err::<(), _>(anyhow!(\n                    \"Cannot save buffer with absolute path\"\n                )))\n                .detach_and_prompt_err(\n                    \"Failed to save\",\n                    window,\n                    cx,\n                    |_, _, _| None,\n                );\n                return;\n            };\n\n            if project.read(cx).entry_for_path(&project_path, cx).is_some()\n                && action.save_intent != Some(SaveIntent::Overwrite)\n            {\n                let answer = window.prompt(\n                    gpui::PromptLevel::Critical,\n                    &format!(\n                        \"{} already exists. Do you want to replace it?\",","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/vim/src/command.rs#L478-L514","documentation":"Raised in the :w/<cmd> write handler register when the filename given in the vim command is an absolute path. Zed's save-with-name only supports relative paths inside a visible worktree (RelPath::new rejects absolute paths), so the write is refused with this error.","triggerScenarios":"Thrown at crates/vim/src/command.rs:496 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Save with a path relative to the worktree root","Add the absolute path's directory as a worktree first"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}