Skip to content

Commit e3575a8

Browse files
committed
Auto merge of rust-lang#16312 - Veykril:win-proc-macro-srv, r=Veykril
fix: Fix rust-analyzer-proc-macro-srv failing to spawn on windows
2 parents acafce3 + a8c94ea commit e3575a8

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
@@ -162,12 +162,19 @@ impl Process {
162162
}
163163

164164
fn mk_child(path: &AbsPath, null_stderr: bool) -> io::Result<Child> {
165-
Command::new(path.as_os_str())
166-
.env("RUST_ANALYZER_INTERNALS_DO_NOT_USE", "this is unstable")
165+
let mut cmd = Command::new(path.as_os_str());
166+
cmd.env("RUST_ANALYZER_INTERNALS_DO_NOT_USE", "this is unstable")
167167
.stdin(Stdio::piped())
168168
.stdout(Stdio::piped())
169-
.stderr(if null_stderr { Stdio::null() } else { Stdio::inherit() })
170-
.spawn()
169+
.stderr(if null_stderr { Stdio::null() } else { Stdio::inherit() });
170+
if cfg!(windows) {
171+
let mut path_var = std::ffi::OsString::new();
172+
path_var.push(path.parent().unwrap().parent().unwrap().as_os_str());
173+
path_var.push("\\bin;");
174+
path_var.push(std::env::var_os("PATH").unwrap_or_default());
175+
cmd.env("PATH", path_var);
176+
}
177+
cmd.spawn()
171178
}
172179

173180
fn send_request(

0 commit comments

Comments
 (0)