rust-lang/rust · 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
Returned by proc-macro-srv-cli's run() when the binary is compiled WITHOUT the in-rust-tree Cargo feature. The stub run() (gated by #[cfg(not(feature = "in-rust-tree"))]) does nothing and immediately fails with ErrorKind::Unsupported. Only the in-rust-tree build contains the real protocol handler; a standalone crates.io-style build is intentionally non-functional.
Source
Thrown at src/tools/rust-analyzer/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 7088e4b63a)
Solutions
- Build the CLI from within the rust workspace / rustup toolchain so the in-rust-tree feature is enabled.
- Add --features in-rust-tree when building standalone: cargo build -p proc-macro-srv-cli --features in-rust-tree.
- Use the rustup-shipped proc-macro-srv (rustup component) instead of a hand-built binary.
- Point rust-analyzer's procMacro.server at a known-good binary from the toolchain.
Example fix
# before # cargo build -p proc-macro-srv-cli # missing feature # after cargo build -p proc-macro-srv-cli --features in-rust-tree
Defensive patterns
Strategy: validation
Validate before calling
fn ensure_in_tree_feature() {
// Assert at startup that the binary supports the protocol.
// Run `proc-macro-srv-cli --help` and check exit code != unsupported.
} Try / catch
match run(stdin, stdout, fmt) {
Ok(()) => Ok(()),
Err(e) if e.kind() == io::ErrorKind::Unsupported
&& e.to_string().contains("in-rust-tree") => {
// tell user to rebuild with --features in-rust-tree
Err(e)
}
Err(e) => Err(e),
} Prevention
- Build proc-macro-srv-cli from the rust workspace or with --features in-rust-tree.
- Prefer the rustup-shipped proc-macro-srv binary.
- Smoke-test the binary (it should not return Unsupported on first request).
When it happens
Trigger: Building proc-macro-srv-cli from source without --features in-rust-tree and then pointing rust-analyzer at the resulting binary. The first request fails instantly with Unsupported because the cfg-gated stub cannot handle stdin/stdout.
Common situations: Building proc-macro-srv-cli standalone (cargo build -p proc-macro-srv-cli) instead of via the rust workspace; vendoring a partial copy of the crate; using a third-party distro package that disabled the feature.
Related errors
- rust-analyzer Language Server is not available. Please, ensu
- Failed to execute ${path} --version.
- Cargo invocation has failed: ${err}
- No compilation artifacts
- Please set `rust-analyzer.profiling.memoryProfile` to the pa
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/59877ecf9115c801.
Report an issue: GitHub.