rust-lang/rust-analyzer · error
{message}
Error message
{message} What it means
show_and_log_error displays an arbitrary message string to the LSP client as a window/showMessage error notification and simultaneously logs it (with optional additional info) to the server's error log. The `{message}` itself is dynamic; it is rust-analyzer's generic channel for surfacing fatal-ish runtime problems to the user.
Source
Thrown at crates/rust-analyzer/src/lsp/utils.rs:75
return;
};
if let Ok(Some(_item)) = crate::from_json::<Option<MessageActionItem>>(
lsp_types::ShowMessageRequest::METHOD.as_str(),
&result,
) {
this.send_notification::<lsp_ext::OpenServerLogsNotification>(());
}
},
),
false => self.send_notification::<lsp_types::ShowMessageNotification>(
lsp_types::ShowMessageParams { kind, message },
),
}
}
/// If `additional_info` is [`Some`], appends a note to the notification telling to check the logs.
/// This will always log `message` + `additional_info` to the server's error log.
pub(crate) fn show_and_log_error(&mut self, message: String, additional_info: Option<String>) {
match additional_info {
Some(additional_info) => {
tracing::error!("{message}:\n{additional_info}");
self.show_message(
lsp_types::MessageType::Error,
message,
tracing::enabled!(tracing::Level::ERROR),
);
}
None => {
tracing::error!("{message}");
self.send_notification::<lsp_types::ShowMessageNotification>(
lsp_types::ShowMessageParams { kind: lsp_types::MessageType::Error, message },
);
}
}
}
View on GitHub (pinned to e8f7e90aa3)
Solutions
- Read the additional info after the colon in the notification and the rust-analyzer output/error log for the root cause.
- For discovery-related messages, fix the workspace/discovery configuration (linkedProjects, custom discovery command).
- If it's a developer poke from a source build, it's informational — verify you built correctly (cargo xtask install vs plain cargo build).
- Reproduce with RUST_LOG=error to capture the full context and file an issue if it's an internal invariant failure.
Defensive patterns
Strategy: fallback
Try / catch
client.onNotification(lsp.ShowMessageNotification.type, (p) => {
if (p.type === lsp.MessageType.Error) {
const [msg, info] = p.message.split(':\n', 2);
log.error(msg, info ?? 'see rust-analyzer output channel');
}
}); Prevention
- Always read the text after ':\n' — it contains the root cause detail.
- Keep the rust-analyzer output channel open at error level when debugging.
- Reproduce with RUST_LOG to capture the full context for bug reports.
When it happens
Trigger: Any code path calling GlobalState::show_and_log_error — notably poke_rust_analyzer_developer (developer-build warnings) and project discovery failures (handle_discover_msg) — passing a formatted message and optional extra info.
Common situations: Running a from-source `cargo xtask install`/POKE_RA_DEVS build that warns developers; project/workspace discovery failing so an error is shown with a hint to check logs; other internal components reporting user-visible failures.
Related errors
- Cannot rename builtin type
- cargo check failed to start: {err}
- Project discovery failed: {error}
- We explicitly do not provide canonicalization API, as that i
- bad kind {other}
AI-assisted analysis of rust-lang/rust-analyzer@e8f7e90aa3 (2026-09-03).
Data as JSON: /api/errors/a491af593cbfbed3.
Report an issue: GitHub.