From 20226da8f6bc2da9f8067742ef26e87afa2c3bc3 Mon Sep 17 00:00:00 2001 From: bilginsenol Date: Tue, 16 Dec 2025 13:21:43 +0300 Subject: [PATCH] Set correct rust-buffer-project for remote buffers rust-buffer-project function calls `cargo locate-project`, which returns the local path to the Cargo.toml. This causes `cargo` commands such as `cargo clippy` executed through the rust-mode to fail (because it is looking for a local path instead of remote host path) if the project is on a remote tramp connection. Fix by prepending "root" with remote prefix if `file-remote-p default-directory` is not nil. --- rust-cargo.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rust-cargo.el b/rust-cargo.el index d323b5d..457ad4f 100644 --- a/rust-cargo.el +++ b/rust-cargo.el @@ -66,7 +66,9 @@ worksapce for commands like `cargo check`." (goto-char 0) (let ((output (let ((json-object-type 'alist)) (json-read)))) - (cdr (assoc-string "root" output))))))) + (concat + (file-remote-p default-directory) + (cdr (assoc-string "root" output)))))))) (defun rust-buffer-crate () "Try to locate Cargo.toml using `locate-dominating-file'." @@ -140,7 +142,7 @@ output buffer will be in comint mode, i.e. interactive." (when (null rust-buffer-project) (rust-update-buffer-project)) (let* ((args (append (list rust-cargo-bin "clippy" - (concat "--manifest-path=" rust-buffer-project)) + (concat "--manifest-path=" (file-local-name rust-buffer-project))) rust-cargo-clippy-default-arguments)) ;; set `compile-command' temporarily so `compile' doesn't ;; clobber the existing value