File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change 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+ ; ; Copy environment variables into the new buffer, since
34+ ; ; with-temp-buffer will re-use the variables' defaults, even if
35+ ; ; they have been changed in this variable using e.g. envrc-mode.
36+ ; ; See https://github.com/purcell/envrc/issues/12.
37+ (let ((env process-environment)
38+ (path exec-path))
39+ (with-temp-buffer
40+ ; ; Copy the entire environment just in case there's something we
41+ ; ; don't know we need.
42+ (setq-local process-environment env)
43+ ; ; Set PATH so we can find cargo.
44+ (setq-local exec-path path)
45+ (let ((ret (call-process rust-cargo-bin nil t nil " locate-project" )))
46+ (when (/= ret 0 )
47+ (error " `cargo locate-project' returned %s status: %s " ret (buffer-string )))
48+ (goto-char 0 )
49+ (let ((output (json-read )))
50+ (cdr (assoc-string " root" output)))))))
4051
4152(defun rust-update-buffer-project ()
4253 (setq-local rust-buffer-project (rust-buffer-project)))
You can’t perform that action at this time.
0 commit comments