`doom-projects.el`: `fd` binary and version detection is broken for TRAMP buffers
- Dominant language
- Emacs Lisp
- Stars
- 22.7k
- Forks
- 3.1k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 4
Description
### I confirm that...
- [X] I have searched the [issue tracker](https://github.com/doomemacs/doomemacs/issues), [documentation](https://docs.doomemacs.org), [FAQ](https://docs.doomemacs.org/-/faq), [Discourse](https://discourse.doomemacs.org), and [Google](https://google.com), in case this issue has already been reported/resolved.
- [X] I have read "[How to Debug Issues](https://doomemacs.org/d/how2debug)", and will use it to provide as much information about this issue as possible.
- [X] The issue can be reproduced on the **latest** available commit of Doom.
- [X] The issue can be reproduced on a stable release of Emacs, such as 27, 28, or 29. *(Unstable versions end in .50, .60, or .9x)*
### Expected behavior
When I open a project over TRAMP connection the `fd` binary (`fd` vs. `fdfind`) and command line arguments (with or without `--strip-cwd-prefix`) should be chosen to match the `fd` installation on the remote host.
### Current behavior
Due to a subtle bug in the lambda expression on lines 181-204 in `doom-projects.el` the automatic detection does not work in TRAMP buffers.
First the `fd` executable is (correctly) resolved with `executable-find`, then an attempt is made to invoke it with `--version` argument to determine if `--strip-cwd-prefix` can be used. The problem is that `doom-call-process` is a wrapper around `call-process`, which executes the process on the local host. As a result _Find file in project_ may be broken for some TRAMP buffers in a few different ways, depending on the exact combination of local and remote `fd` installations.
I believe that the issue can be resolved by using `process-file` instead of `call-process`.
```elisp
(setq projectile-git-submodule-command nil
projectile-indexing-method 'hybrid
projectile-generic-command
(lambda (_)
;; If fd exists, use it for git and generic projects. fd is a rust
;; program that is significantly faster than git ls-files or find, and
;; it respects .gitignore. This is recommended in the projectile docs.
(cond
((when-let*
((bin (if (ignore-errors (file-remote-p default-directory nil t))
(cl-find-if (doom-rpartial #'executable-find t)
(list "fdfind" "fd"))
doom-projectile-fd-binary))
;; REVIEW Temporary fix for #6618. Improve me later.
(version (with-memoization doom-projects--fd-version
(cadr (split-string (cdr (doom-call-process bin "--version"))
" " t))))
((ignore-errors (version-to-list version))))
(concat (format "%s . -0 -H --color=never --type file --type symlink --follow --exclude .git %s"
bin (if (version< version "8.3.0")
"" "--strip-cwd-prefix"))
(if doom--system-windows-p " --path-separator=/"))))
;; Otherwise, resort to ripgrep, which is also faster than find
((executable-find "rg" t)
(concat "rg -0 --files --follow --color=never --hidden -g!.git"
(if doom--system-windows-p " --path-separator=/")))
("find . -type f -print0"))))
```
### Steps to reproduce
1. N/A
### System Information
https://not.applicable
Contributor guide
Assessment
This issue has not been assessed yet.