Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proc macro "main" not expanded + Rust-analyzer not spawning server

I join these two questions in one, as they maybe are related. A few days ago, I started having this error in the [#actix_rt::main] line, before the main function:

proc macro `main` not expanded: cannot find proc-macro server in sysroot `C:\Users\zerok\.rustup\toolchains\stable-x86_64-pc-windows-gnu`

At the same time, in VSCode my rust-analyzer extension started failing. I uninstalled it, restarted VSCode, and reinstalled. It keeps giving the same error over and over:

Failed to spawn one or more proc-macro servers.

How can I fix this problem?

like image 997
Zerok Avatar asked May 08 '26 10:05

Zerok


2 Answers

My problem was related to a setting on VS Code

"rust-analyzer.cargo.sysroot": "discover"

Don't know how but the above setting was set to null. The default is "discover".

like image 113
AndreFDG Avatar answered May 11 '26 02:05

AndreFDG


I had the same problem on Mac, this my error

Failed to spawn one or more proc-macro servers.

- cannot find proc-macro-srv, the workspace 
`/Users/xxxx/vscode/rust/guessing_game` is missing a sysroot

Failed to find sysroot for Cargo.toml file 
/Users/xxxx/vscode/rust/guessing_game/Cargo.toml. Is rust-src installed? 
can't load standard library from sysroot

/Users/xxxx/.rustup/toolchains/stable-x86_64-apple-darwin

(discovered via `rustc --print sysroot`)

try installing the Rust source the same way you installed rustc

here's my fix

# install rust-src
sudo rustup component add rust-src

More information

like image 28
zhangwt Avatar answered May 11 '26 02:05

zhangwt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!