Subject: bug#55386: 29.0.50; check-declare-directory doesn't work on Windows

From: Yasuhiro Kimura <[email-masked]>
Date: Fri, 13 May 2022 02:35:30 +0900 (JST)

From: Lars Ingebrigtsen <[email-masked]>
Subject: Re: bug#55386: 29.0.50; check-declare-directory doesn't work on Windows
Date: Thu, 12 May 2022 17:57:01 +0200

> check-declare-directory is just a wrapper around `find', and I'm surprised
> that this even vaguely works on Windows:
> 
> (defun check-declare-directory (root)
> [...]
>   (let ((files (process-lines-ignore-status
>                 find-program root
>                 "-name" "*.el"
>                 "-exec" grep-program
>                 "-l" "^[ \t]*(declare-function" "{}" "+")))
> 
> If you run this "manually", what does it output?
> 
> -- 
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no

Thanks for reply. And sorry, it seems I misunderstood the problem. At
first I faced the error of check-declare-directory when I tried to
build and install some 3rd party elisp applications. Recently they
start to use the function at their build process and it causes build
error as following.

(MINGW64)yasu@half[1018]% make lisp
make[1]: Entering directory '/c/Users/yasu/Work/Emacs/with-editor/lisp'
Compiling with-editor.el
 Creating with-editor-autoloads.el
 Checking function declarations

Error: file-error ("Opening input file" "Invalid argument" "c:/usr/bin/find: paths must precede expression: `with-editor.el'")
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode -0x10a1f18ad911994>))
  debug-early-backtrace()
  debug-early(error (file-error "Opening input file" "Invalid argument" "c:/usr/bin/find: paths must precede expression: `with-editor.el'"))
  insert-file-contents("/usr/bin/find: paths must precede expression: `with-editor.el'")
  check-declare-scan("/usr/bin/find: paths must precede expression: `with-editor.el'")
  check-declare-files("/usr/bin/find: paths must precede expression: `with-editor.el'" "/usr/bin/find: possible unquoted pattern after predicate `-name'?")
  apply(check-declare-files ("/usr/bin/find: paths must precede expression: `with-editor.el'" "/usr/bin/find: possible unquoted pattern after predicate `-name'?"))
  check-declare-directory("~/Work/Emacs/with-editor/lisp/")
  eval((check-declare-directory default-directory) t)
  command-line-1(("--eval" "(setq with-editor-emacsclient-executable nil)" "-L" "../../compat" "-L" "../../vterm" "-L" "." "--eval" "(check-declare-directory default-directory)"))
  command-line()
  normal-top-level()
Opening input file: Invalid argument, c:/usr/bin/find: paths must precede expression: `with-editor.el'
make[1]: *** [Makefile:14: check-declare] Error 127
make[1]: Leaving directory '/c/Users/yasu/Work/Emacs/with-editor/lisp'
make: *** [Makefile:25: lisp] Error 2
(MINGW64)yasu@half[1019]%  

In this case I executed make.exe from shell of MSYS2. So find.exe and
grep.exe of MSYS2 are used.

But when I directly evaluated check-declare-directory from *scratch*
buffer, I executed emacs from command prompt of Windows. And in this
case there is neither find.exe nor grep.exe in my PATH directories. So
check-declare-directory fails differently. And I wrongly reported it
as the bug of Emacs. Actually if I execute emacs from shell of MSYS2,
then steps of original bug report mail results in expected behavior.

I don't know why above build error happens. But probably it is bug of
the elisp applications in question.  So I'll report it to the author
of them.

Best Regards.

---
Yasuhiro KIMURA