rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Rust-analyzer does not recover from proc-macro errors. Message: "proc-macro server did not respond with data"

Open buildwithzephyr opened this issue 1 year ago • 1 comments

If there are any errors when executing a proc-macro, rust-analyzer will fail on all proc macros until I restart VSCode, even when the macro should work. It gives the error "proc-macro server did not respond with data." It seems that maybe any panic while expanding a proc-macro causes the server to crash and not restart?

rust-analyzer version: Version 0.3.2078, Server Version 0.3.2078-standalone (fa0032624 2024-08-17)

rustc version: rustc 1.78.0 (9b00956e5 2024-04-29)

editor or extension: VSCode, extension version v0.3.2078. I primarily use MacOS, but have seen the same problem on Ubuntu.

relevant settings: I have rust-analyzer set to run on every save, here is my .vscode/settings.json:

{
  "rust-analyzer.showUnlinkedFileNotification": false,
  "[rust]": {
    "editor.defaultFormatter": "rust-lang.rust-analyzer",
    "editor.formatOnSave": true
  }
}

steps to reproduce:

Here is a minimal example using the proc macro subenum:

use subenum::subenum;

#[subenum(A)]
pub enum SomeEnum {
    #[subenum(A, B)]
    A,
    B,
}

The code will fail because the subenum B is specified in the variant attribute, but not in the enum attribute. Rust-analyzer displays the correct error message from the proc macro.

Screenshot 2024-08-22 at 11 26 39 AM

Fix the code by removing B from the variant attribute:

use subenum::subenum;

#[subenum(A)]
pub enum SomeEnum {
    #[subenum(A)]
    A,
    B,
}

This code should now compile. You can confirm this from the terminal with a cargo check.

However, rust-analyzer now fails on the proc-macro again, this time with the message "proc-macro server did not respond with data."

Screenshot 2024-08-22 at 11 32 16 AM

The only way to get rid of this error is to restart VSCode, after which rust-analyzer will handle the macro just fine.

buildwithzephyr avatar Aug 22 '24 19:08 buildwithzephyr

Hmm I can't reproduce this on windows

Veykril avatar Aug 23 '24 07:08 Veykril

I get same errors from Zed+RA (any version, including nightly) on macOS.

Language server rust-analyzer:

Failed spawning proc-macro server for workspace `/Users/___/proj/Cargo.toml`: Failed to run proc-macro server from path /Users/___/.rustup/toolchains/nightly-aarch64-apple-darwin/libexec/rust-analyzer-proc-macro-srv, error: Custom { kind: Other, error: "proc-macro server version check failed: proc-macro server exited with exit status: 101" }

Update: Hmmm, that's interesting. Just calling RUST_ANALYZER_INTERNALS_DO_NOT_USE=1 ~/.rustup/toolchains/nightly-aarch64-apple-darwin/libexec/rust-analyzer-proc-macro-srv returns permission error: Custom { kind: PermissionDenied, error: "error creating directory \"/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/proc-macro-srv82bf-0\": Permission denied (os error 13)" } after unwrapping Result with it in the ProcMacroSrv::new somewhere. But it has permissions .rwxr-xr-x.

If I run it with sudo (sorry, gods) and keep it alive, RA throws version-check error (looks like this one) : Custom { kind: Other, error: "proc-macro server version check failed: proc-macro server exited with exit status: 101" }.

Versions:

  • rust-analyzer-proc-macro-srv 1.93.0-nightly (292be5c7 2025-10-29)
  • rust-analyzer 1.93.0-nightly (292be5c7 2025-10-29)

boozook avatar Oct 31 '25 10:10 boozook

hmm, 101 I think is the panic exit code in Rust, so it sounds like its panicking on something else

Veykril avatar Oct 31 '25 11:10 Veykril