{"record":{"id":"0abeee519f52c02a","repo":"zed-industries/zed","slug":"copilot-was-not-started-because-of-an-error-erro","errorCode":null,"errorMessage":"copilot was not started because of an error: {error}","messagePattern":"copilot was not started because of an error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/copilot/src/copilot.rs","lineNumber":79,"sourceCode":"    Running(RunningCopilotServer),\n}\n\nimpl CopilotServer {\n    fn as_authenticated(&mut self) -> Result<&mut RunningCopilotServer> {\n        let server = self.as_running()?;\n        anyhow::ensure!(\n            matches!(server.sign_in_status, SignInStatus::Authorized),\n            \"must sign in before using copilot\"\n        );\n        Ok(server)\n    }\n\n    fn as_running(&mut self) -> Result<&mut RunningCopilotServer> {\n        match self {\n            CopilotServer::Starting { .. } => anyhow::bail!(\"copilot is still starting\"),\n            CopilotServer::Disabled => anyhow::bail!(\"copilot is disabled\"),\n            CopilotServer::Error(error) => {\n                anyhow::bail!(\"copilot was not started because of an error: {error}\")\n            }\n            CopilotServer::Running(server) => Ok(server),\n        }\n    }\n}\n\nstruct RunningCopilotServer {\n    lsp: Arc<LanguageServer>,\n    sign_in_status: SignInStatus,\n    registered_buffers: HashMap<EntityId, RegisteredBuffer>,\n}\n\n#[derive(Clone, Debug)]\nenum SignInStatus {\n    Authorized,\n    Unauthorized,\n    SigningIn {\n        prompt: Option<request::PromptUserDeviceFlow>,","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/copilot/src/copilot.rs#L61-L97","documentation":"The third branch of as_running(): startup was attempted and failed, and the failure was stored in CopilotServer::Error(error). This bail re-raises that stored cause with a wrapper message, so the {error} text after the colon is the real diagnosis — typically a binary-install failure, unsupported platform/arch (see errors 178/179), an npm error, or the language server process dying at spawn. The state is sticky: every subsequent call re-surfaces the same stored error until Copilot is restarted or reinstalled.","triggerScenarios":"Any Copilot API call after start_copilot failed — e.g. npm install of copilot-language-server errored (registry unreachable, disk full), the platform/arch is unsupported, or the spawned process exited immediately; the stored error then bubbles through as_running() on all later calls.","commonSituations":"Offline or proxied network blocking npm download of the language server package; corporate npm registry mirror missing @github/copilot-language-server-*; out-of-disk in the copilot directory; OS/arch combination with no prebuilt binary (freebsd, 32-bit); stale half-written install from an interrupted update.","solutions":["Read the {error} suffix first — it is the actual failure; fix that cause (network, disk, registry) rather than this wrapper","Use the built-in reinstall path (Copilot::reinstall) to re-download the language server after fixing the environment","Clear the copilot directory (paths::copilot_dir) if a previous partial install is suspected, then retry","Verify the platform/arch is linux/macOS/windows on x64/arm64; otherwise Copilot cannot run (see errors 178/179)"],"exampleFix":"# before: error stored, every call re-fails\n# 'copilot was not started because of an error: ... npm ENOTFOUND registry.npmjs.org'\n\n# after: fix network/DNS, then trigger reinstall\n# editor: run 'copilot: reinstall' (Copilot::reinstall) and retry sign-in","handlingStrategy":"try-catch","validationCode":"use copilot::Status;\n\nif let Status::Error(msg) = copilot.read(cx).status() {\n    // stale stored failure — trigger reinstall before invoking APIs\n    copilot.update(cx, |c, cx| { c.reinstall(cx); });\n    return Task::ready(Err(anyhow!(\"copilot startup failed earlier: {msg}\")));\n}","typeGuard":"fn copilot_in_error(copilot: &Entity<Copilot>, cx: &App) -> Option<String> {\n    match copilot.read(cx).status() {\n        Status::Error(msg) => Some(msg),\n        _ => None,\n    }\n}","tryCatchPattern":"match result {\n    Err(err) if err.to_string().contains(\"was not started because of an error\") => {\n        // the suffix after the colon is the real cause; it is sticky until reinstall/restart\n        diagnose_stored_error(&err);\n        copilot.update(cx, |c, cx| { c.reinstall(cx); }); // recovery path\n    }\n    other => other,\n}","preventionTips":["Always read the {error} suffix — the wrapper is only a carrier for the stored cause","After fixing the environment (npm access, disk, platform), run reinstall rather than expecting auto-recovery","Clear paths::copilot_dir() when a partial install is suspected"],"tags":["copilot","lifecycle","startup-failure","language-server","npm"],"backgroundTag":"service-startup-failed","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}