Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a8c94ea

Browse files
committed
fix: Fix rust-analyzer-proc-macro-srv failing to spawn on windows
1 parent f5f7dda commit a8c94ea

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

crates/proc-macro-api/src/process.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,19 @@ impl Process {
131131
}
132132

133133
fn mk_child(path: &AbsPath, null_stderr: bool) -> io::Result<Child> {
134-
Command::new(path.as_os_str())
135-
.env("RUST_ANALYZER_INTERNALS_DO_NOT_USE", "this is unstable")
134+
let mut cmd = Command::new(path.as_os_str());
135+
cmd.env("RUST_ANALYZER_INTERNALS_DO_NOT_USE", "this is unstable")
136136
.stdin(Stdio::piped())
137137
.stdout(Stdio::piped())
138-
.stderr(if null_stderr { Stdio::null() } else { Stdio::inherit() })
139-
.spawn()
138+
.stderr(if null_stderr { Stdio::null() } else { Stdio::inherit() });
139+
if cfg!(windows) {
140+
let mut path_var = std::ffi::OsString::new();
141+
path_var.push(path.parent().unwrap().parent().unwrap().as_os_str());
142+
path_var.push("\\bin;");
143+
path_var.push(std::env::var_os("PATH").unwrap_or_default());
144+
cmd.env("PATH", path_var);
145+
}
146+
cmd.spawn()
140147
}
141148

142149
fn send_request(

0 commit comments

Comments
 (0)