From c7323654ca192ef8cadffe645b1d387cf4058ad5 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Fri, 25 Sep 2026 22:23:49 +0200 Subject: [PATCH] Fix rust_analyzer_proc_macro_srv on Windows by setting PATH in launcher This effectively resolves "..\..\bin" from the target exe, and adds that to PATH, enabling the dlls for rust_analyzer_proc_macro_srv to be located. I'm not sure this is the best way to go about this, but I'm committing it in case it's useful for somebody else or a maintainer has a better idea. Fixes https://github.com/bazelbuild/rules_rust/issues/4285 --- tools/rust_analyzer/bin/launcher.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/rust_analyzer/bin/launcher.rs b/tools/rust_analyzer/bin/launcher.rs index 6d335cb536..7a303883b7 100644 --- a/tools/rust_analyzer/bin/launcher.rs +++ b/tools/rust_analyzer/bin/launcher.rs @@ -59,7 +59,21 @@ fn exec_replace(target: &Path) -> ! { #[cfg(not(unix))] fn exec_replace(target: &Path) -> ! { - let status = process::Command::new(target) + let mut cmd = process::Command::new(target); + + // On Windows, ensure the respective bin/ folder is on PATH. + // This is necessary for rust_analyzer_proc_macro_srv, as it's in libexec/ + // and otherwise would be missing .dlls + #[cfg(windows)] + if let Some(sys_root) = target.parent().and_then(Path::parent) { + let bin_dir = sys_root.join("bin"); + let mut path = std::env::var_os("PATH").unwrap_or("".into()); + path.push(";"); + path.push(bin_dir); + cmd.env("PATH", path); + } + + let status = cmd .args(env::args_os().skip(1)) .status() .unwrap_or_else(|e| die(format!("spawn {}: {e}", target.display())));