{"record":{"id":"ee80116268aa6e46","repo":"PRQL/prql","slug":"err","errorCode":null,"errorMessage":"{err}","messagePattern":"\\{err\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"prqlc/prqlc/src/cli/mod.rs","lineNumber":351,"sourceCode":"                Ok(())\n            }\n            Command::Debug(DebugCommand::Ast) => {\n                prqlc::ir::pl::print_mem_sizes();\n                Ok(())\n            }\n            Command::Debug(DebugCommand::JsonSchema { ir_type }) => {\n                let schema = match ir_type {\n                    IntermediateRepr::Pl => schema_for!(pl::ModuleDef),\n                    IntermediateRepr::Rq => schema_for!(rq::RelationalQuery),\n                    IntermediateRepr::Lineage => schema_for!(FrameCollector),\n                };\n                io::stdout().write_all(&serde_json::to_string_pretty(&schema)?.into_bytes())?;\n                Ok(())\n            }\n            #[cfg(feature = \"lsp\")]\n            Command::Lsp => match lsp::run() {\n                Ok(_) => Ok(()),\n                Err(err) => Err(anyhow!(err)),\n            },\n            // Without the feature there's no server to start. This has to be\n            // handled here rather than falling through to `run_io_command`,\n            // which has no `IoArgs` to work with and would panic.\n            #[cfg(not(feature = \"lsp\"))]\n            Command::Lsp => Err(anyhow!(\n                \"`lsp` requires `prqlc` to be built with the `lsp` feature\"\n            )),\n            _ => self.run_io_command(),\n        }\n    }\n\n    fn list_targets(&self) -> std::result::Result<(), anyhow::Error> {\n        println!(\"{}\", Target::names().join(\"\\n\"));\n        Ok(())\n    }\n\n    fn run_io_command(&mut self) -> std::result::Result<(), anyhow::Error> {","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc/src/cli/mod.rs#L333-L369","documentation":"When the `lsp` feature is compiled in, `prqlc lsp` starts the language server; any error from lsp::run() is wrapped with anyhow! and returned as the command's error, so the message body is the underlying LSP error text. Without the feature there is a separate static message, so this variant only appears in LSP-enabled builds.","triggerScenarios":"Running `prqlc lsp` in a build with the lsp feature enabled while the server fails to start or dies — port/binding issues, transport (stdio) broken pipe, initialization failure in the LSP loop.","commonSituations":"Editor clients (VS Code, Neovim) launching prqlc lsp and the server erroring during handshake or when the client closes the pipe; running the binary manually to debug an editor setup.","solutions":["Read the wrapped inner error text and address the underlying cause (binding, transport, missing tool)","Verify your editor client sends a correct LSP initialize request before other messages","Update prqlc to the latest version — LSP bugs are frequently fixed upstream","Run the server manually with RUST_LOG=debug to capture detailed logs"],"exampleFix":"// before (swallowing context)\nErr(err) => Err(anyhow!(err)),\n// after (caller-side: capture logs to diagnose)\nRUST_LOG=debug prqlc lsp 2>lsp.log\n","handlingStrategy":"try-catch","validationCode":"# Confirm lsp feature and check server starts\nprqlc --version && timeout 2 sh -c 'prqlc lsp < /dev/null'; echo \"exit=$?\"","typeGuard":null,"tryCatchPattern":"// Editor client side: handle server exit and log stderr\nserver.on('exit', (code) => console.error(`prqlc lsp exited: ${code}`));\ntry { await client.start(); } catch (e) { console.error('LSP start failed', e); }","preventionTips":["Launch prqlc lsp only through a compliant LSP client","Capture stderr logs (RUST_LOG=debug) when integrating","Keep prqlc updated for LSP fixes"],"tags":["cli","lsp","error-wrapping"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e164e249b99485890036eb60f57c37520379b240","analyzedAt":"2026-09-09T12:18:38.727Z","contentChangedAt":"2026-09-09T12:18:38.727Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}