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
bkmoney
  • 323
  • 3
  • 10
  • 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 '15 at 01:15
  • I have added cygwin to the beginning of my path and I still get this error. – bkmoney Feb 27 '15 at 01: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 https://github.com/junjiemars/.emacs.d/blob/master/config/on-grep-autoload.el – 南山竹 Jul 24 '18 at 06:26

2 Answers2

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")
Tatu Lahtela
  • 181
  • 1
  • 2
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.

glucas
  • 20,563
  • 1
  • 54
  • 84
  • 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 07 '22 at 12:51