{"record":{"id":"a08f334ddd418c0c","repo":"zed-industries/zed","slug":"default-prettier-is-not-installed-and-cannot-be-st","errorCode":null,"errorMessage":"Default prettier is not installed and cannot be started","messagePattern":"Default prettier is not installed and cannot be started","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/project/src/prettier_store.rs","lineNumber":335,"sourceCode":"    fn start_default_prettier(\n        node: NodeRuntime,\n        worktree_id: Option<WorktreeId>,\n        cx: &mut Context<PrettierStore>,\n    ) -> Task<anyhow::Result<PrettierTask>> {\n        cx.spawn(async move |prettier_store, cx| {\n            let installation_task = prettier_store.read_with(cx, |prettier_store, _| {\n                match &prettier_store.default_prettier.prettier {\n                    PrettierInstallation::NotInstalled {\n                        installation_task, ..\n                    } => ControlFlow::Continue(installation_task.clone()),\n                    PrettierInstallation::Installed(default_prettier) => {\n                        ControlFlow::Break(default_prettier.clone())\n                    }\n                }\n            })?;\n            match installation_task {\n                ControlFlow::Continue(None) => {\n                    anyhow::bail!(\"Default prettier is not installed and cannot be started\")\n                }\n                ControlFlow::Continue(Some(installation_task)) => {\n                    log::info!(\"Waiting for default prettier to install\");\n                    if let Err(e) = installation_task.await {\n                        prettier_store.update(cx, |project, _| {\n                            if let PrettierInstallation::NotInstalled {\n                                installation_task,\n                                attempts,\n                                ..\n                            } = &mut project.default_prettier.prettier\n                            {\n                                *installation_task = None;\n                                *attempts += 1;\n                            }\n                        })?;\n                        anyhow::bail!(\n                            \"Cannot start default prettier due to its installation failure: {e:#}\"\n                        );","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/project/src/prettier_store.rs#L317-L353","documentation":"When a project has no prettier in node_modules, Zed falls back to a globally managed \"default prettier\" installed into default_prettier_dir(). start_default_server inspects the PrettierInstallation state; NotInstalled with no pending installation_task means there is nothing to start or await right now (crates/project/src/prettier_store.rs:335), so it bails.","triggerScenarios":"Triggering prettier formatting while default_prettier is PrettierInstallation::NotInstalled with installation_task == None - e.g. a previous auto-install failed and the store cleared the task and bumped its attempts counter, or installation was never started for this worktree.","commonSituations":"Node/npm missing or offline during the first format of a project; retrying format right after a failed auto-install; formatting requested while the store is still initializing.","solutions":["Install prettier in the project itself (npm i -D prettier) - Zed prefers node_modules prettier and skips the default entirely","Verify node -v and npm -v work in the environment Zed launches from, then retrigger formatting or restart Zed so a fresh install task starts","If it keeps landing here, inspect the paired \"Cannot start default prettier due to its installation failure\" error for the root cause"],"exampleFix":"# before: project has no prettier, default install unavailable\nformat on save -> \"Default prettier is not installed and cannot be started\"\n\n# after\nnpm install --save-dev prettier\n# formatting now uses ./node_modules/prettier","handlingStrategy":"fallback","validationCode":"# shell pre-check before relying on the default prettier\n[ -d node_modules/prettier ] && echo \"local prettier present\" || npm install --save-dev prettier","typeGuard":null,"tryCatchPattern":"match start_default_prettier(node, worktree_id, cx).await {\n    Ok(server) => server,\n    Err(e) if e.to_string().contains(\"Default prettier is not installed\") => {\n        // fall back to the language server's built-in formatter\n        format_via_language_server(buffer, cx).await\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Commit prettier as a project devDependency so the global default never matters","Verify node/npm availability before selecting prettier as the default formatter"],"tags":["prettier","formatting","node","npm","installation"],"backgroundTag":"formatter-not-installed","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"}