Proc macro server error: LoadLibraryExW failed for clap Parser macro
⚓ Rust 📅 2026-06-08 👤 surdeus 👁️ 1I'm trying to get the example implementation from the "clap" crate working, as below:
use clap::Parser;
/// Simple program to greet a person
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
/// Name of the person to greet
#[arg(short, long)]
name: String,
/// Number of times to greet
#[arg(short, long, default_value_t = 1)]
count: u8,
}
fn main() {
let args = Args::parse();
for _ in 0..args.count {
println!("Hello {}!", args.name);
}
}
However, it fails on the derive macro for Args, with the following error:
proc macro server error: Cannot create expander for C:\<path to clap_derive-d7e84929d03230d8.dll>: LoadLibraryExW failed
I am running the above on Windows 11 in Visual Studio Code, with:
- clap v4.6.1
- rust-analyzer v0.3.2929
- cargo v1.96.0
- rustup v1.29.0
I've tried the following solutions:
cargo updatecargo clean- Switching rust-analyzer to pre-release
- Changing the toolchain from
stable-x86_64-pc-windows-gnutostable-x86_64-pc-windows-msvc(and vice versa) - In settings.json, changing
rust-analyzer.rustc.sourcetodiscover
None of the above works.
2 posts - 2 participants
🏷️ Rust_feed