zed-industries/zed · error · anyhow::Error

Cannot start default prettier due to its installation failur

Error message

Cannot start default prettier due to its installation failure: {e:#}

What it means

The background task installing the default (Zed-managed global) prettier finished with an error. The store reacts by clearing installation_task and incrementing the attempts counter, then bails with the full error chain ({e:#}) - so the text after the colon carries the actual cause (missing node, spawn failure, network error, permissions).

Source

Thrown at crates/project/src/prettier_store.rs:351

            match installation_task {
                ControlFlow::Continue(None) => {
                    anyhow::bail!("Default prettier is not installed and cannot be started")
                }
                ControlFlow::Continue(Some(installation_task)) => {
                    log::info!("Waiting for default prettier to install");
                    if let Err(e) = installation_task.await {
                        prettier_store.update(cx, |project, _| {
                            if let PrettierInstallation::NotInstalled {
                                installation_task,
                                attempts,
                                ..
                            } = &mut project.default_prettier.prettier
                            {
                                *installation_task = None;
                                *attempts += 1;
                            }
                        })?;
                        anyhow::bail!(
                            "Cannot start default prettier due to its installation failure: {e:#}"
                        );
                    }
                    let new_default_prettier =
                        prettier_store.update(cx, |prettier_store, cx| {
                            let new_default_prettier = Self::start_prettier(
                                node,
                                default_prettier_dir().clone(),
                                worktree_id,
                                cx,
                            );
                            prettier_store.default_prettier.prettier =
                                PrettierInstallation::Installed(PrettierInstance {
                                    attempt: 0,
                                    prettier: Some(new_default_prettier.clone()),
                                });
                            new_default_prettier
                        })?;

View on GitHub (pinned to f4178619ac)

Solutions

  1. Read the chained message after the colon - it names the real failure
  2. Install Node.js/npm and confirm node -v and npm -v run in Zed's environment
  3. Check network/proxy reachability of registry.npmjs.org, then restart Zed to retry the install
  4. Sidestep the global install entirely with a project-local prettier: npm i -D prettier

Example fix

# before
$ node -v
zsh: command not found: node

# after (install node, restart Zed, re-trigger format)
$ node -v
v22.14.0
Defensive patterns

Strategy: retry

Validate before calling

$ node -v && npm -v   # both must succeed before prettier auto-install can work

Try / catch

match start_default_prettier(node, worktree_id, cx).await {
    Err(e) if e.to_string().contains("installation failure") => {
        // inspect {e:#} chain, fix node/npm/network, then restart Zed to retry
        Err(e)
    }
    other => other,
}

Prevention

When it happens

Trigger: installation_task.await returns Err - npm or node not on PATH, no network access to registry.npmjs.org, or a write failure in the global prettier directory - followed by an attempt to start the default prettier server.

Common situations: No Node.js installed; corporate proxy blocking the npm registry; first format in a new project on a locked-down machine.

Related errors


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