6

I'm running GNU Emacs on Windows 7 and was just wondering how to set up emacs so the "find-name-dired" command works. When I try using find-name-dired to recursively search for files I get this:

find . "(" -iname "*.tex" ")" -exec ls -ld {} ";"
File not found - "*.tex"  
find exited abnormally with code 2 at Thu Feb 26 16:58:31
3
  • 1
    I'm pretty sure find is part of the GNU findutils, which is generally runs on GNU systems (i.e. not Windows). You may need to look into Cygwin/MSYS.
    – PythonNut
    Feb 27, 2015 at 1:15
  • I have added cygwin to the beginning of my path and I still get this error.
    – bkmoney
    Feb 27, 2015 at 1:27
  • When using GNU’s find program on Windows should be favored using executable-find% to checkout GNU’s find over Windows builtin find program. See github.com/junjiemars/.emacs.d/blob/master/config/…
    – 南山竹
    Jul 24, 2018 at 6:26

2 Answers 2

8

I'll add this solution here as modifying the PATH can have unwanted side effects elsewhere. To set the find program to the wanted find.exe, for example provided by git:

(setq find-program "c:/Git/usr/bin/find.exe")
1
  • I needed to do (setq find-program "C:\\Users\\rnwol\\scoop\\shims\\find.exe") Nov 6, 2019 at 12:20
3

Emacs relies on various Unix tools, including find. On Windows you can install a Unix-style shell such as Cygwin, or just install ports of the specific tools you need. There are several options - I'm currently using tools from ezwinports.

Whatever you choose, you'll need to make sure that the Unix find command is on the path ahead of Windows one. You can do that with environment variables before starting emacs, or add to the emacs exec-path.

1
  • If your Git's find.exe is in the Program Files folder, the space in the command name can confuse emacs / Windows -- for me, doing (setq find-program "\"C:\\Program Files\\Git\\usr\\bin\\find.exe\"") works. (The key bit seemed to be getting the double quote characters passed down.)
    – Dan Drake
    Jan 7, 2022 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.