rust-lang/rust-analyzer · error · io::Error
proc-macro-srv-cli needs to be compiled with the `in-rust-tr
Error message
proc-macro-srv-cli needs to be compiled with the `in-rust-tree` feature to function
What it means
This error is returned by the stub `run` function that is compiled when the `in-rust-tree` cargo feature is disabled. The binary ships two implementations of `run`: a real one that reads requests from stdin and dispatches proc-macro expansions, and this no-op guard that simply errors out. It fires whenever the user invokes proc-macro-srv-cli built without the feature, because only `in-rust-tree` builds link against the rustc driver and the proc-macro bridge needed to expand macros; a standalone build has no expansion backend, so any attempt to run it aborts immediately with this sentinel error.
Source
Thrown at crates/proc-macro-srv-cli/src/main.rs:100
fn from_str(input: &str, _ignore_case: bool) -> Result<Self, String> {
match input {
"json-legacy" => Ok(ProtocolFormatArg(ProtocolFormat::JsonLegacy)),
"bidirectional-postcard-prototype" => {
Ok(ProtocolFormatArg(ProtocolFormat::BidirectionalPostcardPrototype))
}
_ => Err(format!("unknown protocol format: {input}")),
}
}
}
#[cfg(not(feature = "in-rust-tree"))]
fn run(
_: &mut std::io::BufReader<std::io::Stdin>,
_: &mut std::io::Stdout,
_: ProtocolFormat,
) -> std::io::Result<()> {
Err(std::io::Error::new(
std::io::ErrorKind::Unsupported,
"proc-macro-srv-cli needs to be compiled with the `in-rust-tree` feature to function"
.to_owned(),
))
}
View on GitHub (pinned to e8f7e90aa3)
Solutions
- Rebuild or reinstall the binary with the `in-rust-tree` feature enabled (e.g. `cargo build --features in-rust-tree`)
- Use the rustup-distributed rust-analyzer, whose proc-macro-srv component is built in-tree with the required feature
- Prefer invoking proc-macro expansion through rust-analyzer, which spawns a compatible proc-macro-srv automatically
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/proc-macro-srv-cli/src/main.rs:100 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rust-lang/rust-analyzer@e8f7e90aa3 (2026-09-03).
Data as JSON: /api/errors/b9dd6855d8220d25.
Report an issue: GitHub.