{"record":{"id":"e7b659cdf1d63677","repo":"Kuberwastaken/claurst","slug":"failed-to-start-lsp-server","errorCode":null,"errorMessage":"Failed to start LSP server '{}': {}","messagePattern":"Failed to start LSP server '(.+?)': (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"src-rust/crates/core/src/lsp.rs","lineNumber":209,"sourceCode":"            .stdin(std::process::Stdio::piped())\r\n            .stdout(std::process::Stdio::piped())\r\n            .stderr(std::process::Stdio::piped())\r\n            .kill_on_drop(true);\r\n\r\n        // Inject environment variables\r\n        for (k, v) in &config.env {\r\n            cmd.env(k, v);\r\n        }\r\n\r\n        // On Windows, suppress the console window (CREATE_NO_WINDOW = 0x0800_0000).\r\n        // tokio::process::Command exposes creation_flags() directly on Windows.\r\n        #[cfg(target_os = \"windows\")]\r\n        {\r\n            cmd.creation_flags(0x0800_0000u32);\r\n        }\r\n\r\n        let mut child = cmd.spawn().map_err(|e| {\r\n            anyhow::anyhow!(\r\n                \"Failed to start LSP server '{}': {}\",\r\n                config.command,\r\n                e\r\n            )\r\n        })?;\r\n\r\n        let stdin = child\r\n            .stdin\r\n            .take()\r\n            .ok_or_else(|| anyhow::anyhow!(\"LSP server stdin not available\"))?;\r\n        let stdout = child\r\n            .stdout\r\n            .take()\r\n            .ok_or_else(|| anyhow::anyhow!(\"LSP server stdout not available\"))?;\r\n\r\n        let pending: PendingMap = Arc::new(DashMap::new());\r\n        let diagnostics: Arc<DashMap<String, Vec<LspDiagnostic>>> =\r\n            Arc::new(DashMap::new());\r","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/core/src/lsp.rs#L191-L227","documentation":"`LspClient::start` failed to spawn the configured language-server executable. `tokio::process::Command::spawn` returned an OS error (typically ENOENT, permission denied, or exec-format error), and the library wraps it with the configured command name for context. This happens before any LSP protocol exchange, so no server process exists.","triggerScenarios":"Calling `LspClient::start(config)` where `config.command` is not on PATH, points to a nonexistent file, lacks the executable bit, or fails to exec (e.g. wrong interpreter shebang, wrong-architecture binary, or a .cmd/.bat path on Windows without a shell).","commonSituations":"Typo'd command like 'rust-anaylzer'; server not installed (no `rust-analyzer`, `gopls`, `pyright` in PATH); running under systemd/CI with a minimal PATH missing ~/.cargo/bin or npm global bin; executable bit stripped after download; server requires an interpreter (node/python) that isn't installed.","solutions":["Verify the server binary exists and is runnable: `which <command>` / `command -v <command>`, then run it directly with `--version`.","Install the language server (rustup component add rust-analyzer, npm i -g pyright, etc.) or set `config.command` to its absolute path.","If the binary lives outside the default PATH of the invoking environment, add its directory to PATH or use an absolute path in LspServerConfig.","Check config.env entries aren't clobbering PATH or other vars the launcher needs.","On Windows, invoke .cmd/.bat wrappers via cmd /c or point directly at the .exe."],"exampleFix":"// before\nlet cfg = LspServerConfig { name: \"rust\".into(), command: \"rust-anaylzer\".into(), args: vec![], env: Default::default() };\n// after\nlet cfg = LspServerConfig { name: \"rust\".into(), command: \"/usr/bin/rust-analyzer\".into(), args: vec![], env: Default::default() };","handlingStrategy":"validation","validationCode":"fn assert_server_available(command: &str, args: &[String]) -> std::io::Result<()> {\n    let mut cmd = std::process::Command::new(command);\n    cmd.args(args).arg(\"--version\").stdout(std::process::Stdio::null()).stderr(std::process::Stdio::null());\n    cmd.status().map(|_| ())\n}","typeGuard":null,"tryCatchPattern":"match LspClient::start(config).await {\n    Ok(client) => client,\n    Err(e) if e.to_string().contains(\"Failed to start LSP server\") => {\n        eprintln!(\"server '{}' missing or not executable: {e}\", config.command);\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Resolve the server binary to an absolute path in config instead of relying on PATH.","Run `which <server>` / `<server> --version` as a startup health check.","Pin the server install in setup scripts (rustup component add, npm i -g) so environments are consistent.","Beware CI/container PATH differences; export needed dirs explicitly."],"tags":["lsp","process-spawn","command-not-found","rust"],"backgroundTag":"command-not-found","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}