{"record":{"id":"59877ecf9115c801","repo":"rust-lang/rust","slug":"proc-macro-srv-cli-needs-to-be-compiled-with-the","errorCode":null,"errorMessage":"proc-macro-srv-cli needs to be compiled with the `in-rust-tree` feature to function","messagePattern":"proc-macro-srv-cli needs to be compiled with the `in-rust-tree` feature to function","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main.rs","lineNumber":100,"sourceCode":"\n    fn from_str(input: &str, _ignore_case: bool) -> Result<Self, String> {\n        match input {\n            \"json-legacy\" => Ok(ProtocolFormatArg(ProtocolFormat::JsonLegacy)),\n            \"bidirectional-postcard-prototype\" => {\n                Ok(ProtocolFormatArg(ProtocolFormat::BidirectionalPostcardPrototype))\n            }\n            _ => Err(format!(\"unknown protocol format: {input}\")),\n        }\n    }\n}\n\n#[cfg(not(feature = \"in-rust-tree\"))]\nfn run(\n    _: &mut std::io::BufReader<std::io::Stdin>,\n    _: &mut std::io::Stdout,\n    _: ProtocolFormat,\n) -> std::io::Result<()> {\n    Err(std::io::Error::new(\n        std::io::ErrorKind::Unsupported,\n        \"proc-macro-srv-cli needs to be compiled with the `in-rust-tree` feature to function\"\n            .to_owned(),\n    ))\n}\n","sourceCodeStart":82,"sourceCodeEnd":106,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main.rs#L82-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\n# cargo build -p proc-macro-srv-cli   # missing feature\n\n# after\ncargo build -p proc-macro-srv-cli --features in-rust-tree","handlingStrategy":"validation","validationCode":"fn ensure_in_tree_feature() {\n    // Assert at startup that the binary supports the protocol.\n    // Run `proc-macro-srv-cli --help` and check exit code != unsupported.\n}","typeGuard":null,"tryCatchPattern":"match run(stdin, stdout, fmt) {\n    Ok(()) => Ok(()),\n    Err(e) if e.kind() == io::ErrorKind::Unsupported\n        && e.to_string().contains(\"in-rust-tree\") => {\n        // tell user to rebuild with --features in-rust-tree\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["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)."],"tags":["rust-analyzer","proc-macro","build","feature-flag","configuration"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}