Skip to content

Commit 1d4b327

Browse files
committed
Pass process-environment and exec-path through with-temp-buffer
This is the only place in rust-mode where we actually shell out, so I didn't extract this as a macro, but merely made the change in the one place it was necessary.
1 parent 5f654a5 commit 1d4b327

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

rust-cargo.el

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@
3030

3131
(defun rust-buffer-project ()
3232
"Get project root if possible."
33-
(with-temp-buffer
34-
(let ((ret (call-process rust-cargo-bin nil t nil "locate-project")))
35-
(when (/= ret 0)
36-
(error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))
37-
(goto-char 0)
38-
(let ((output (json-read)))
39-
(cdr (assoc-string "root" output))))))
33+
(let ((env process-environment)
34+
(path exec-path))
35+
(with-temp-buffer
36+
(setq-local process-environment env)
37+
(setq-local exec-path path)
38+
(let ((ret (call-process rust-cargo-bin nil t nil "locate-project")))
39+
(when (/= ret 0)
40+
(error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))
41+
(goto-char 0)
42+
(let ((output (json-read)))
43+
(cdr (assoc-string "root" output)))))))
4044

4145
(defun rust-update-buffer-project ()
4246
(setq-local rust-buffer-project (rust-buffer-project)))

0 commit comments

Comments
 (0)