Subject: Re: bug#65763: Error opening a file from a Git working directory if Git is not installed

From: Paul Pogonyshev <[email-masked]>
Date: Tue, 5 Sep 2023 22:14:15 +0200

Ah, `debug-on-error' makes `with-demoted-errors' not demote it.

It seems in my case `debug-on-error' is let-bound in
`ert--run-test-internal'. I.e. when file is failed to be opened inside a
ERT-based test, there is no warning, it's a hard error. I happen to run ERT
tests inside a Docker container.

I'm not sure if it is a bug, but it does cause problems.

Paul

On Tue, 5 Sept 2023 at 22:06, Paul Pogonyshev <[email-masked]> wrote:

> From what I see it's not just a warning:
>
> $ emacs --batch --eval "(let ((debug-on-error t)) (setf vc-git-program
> \"git-is-not-installed\") (find-file-noselect \"whatever\"))"
> Debugger entered--Lisp error: (file-missing "Searching for program" "No
> such file or directory" "git-is-not-installed")
>   call-process("git-is-not-installed" nil (t nil) nil "--no-pager"
> "ls-files" "-c" "-z" "--" "whatever")
>   process-file("git-is-not-installed" nil (t nil) nil "--no-pager"
> "ls-files" "-c" "-z" "--" "whatever")
>   vc-git--call((t nil) "ls-files" "-c" "-z" "--" "whatever")
>   vc-git--out-ok("ls-files" "-c" "-z" "--" "whatever")
>   vc-git-registered("/home/paul/eldev/whatever")
>   vc-git-registered("/home/paul/eldev/whatever")
>   vc-call-backend(Git registered "/home/paul/eldev/whatever")
>   #f(compiled-function (b) #<bytecode 0x15a622e462a366fe>)(Git)
>   mapc(#f(compiled-function (b) #<bytecode 0x15a622e462a366fe>) (RCS CVS
> SVN SCCS SRC Bzr Git Hg))
>   vc-registered("/home/paul/eldev/whatever")
>   vc-backend("/home/paul/eldev/whatever")
>   vc-refresh-state()
>   run-hooks(find-file-hook)
>   after-find-file(t t)
>   find-file-noselect-1(#<buffer whatever> "~/eldev/whatever" nil nil
> "~/eldev/whatever" nil)
>   find-file-noselect("whatever")
>   (let ((debug-on-error t)) (setf vc-git-program "git-is-not-installed")
> (find-file-noselect "whatever"))
>   command-line-1(("--eval" "(let ((debug-on-error t)) (setf vc-git-program
> \"gi..."))
>   command-line()
>   normal-top-level()
>
> Paul
>
> On Tue, 5 Sept 2023 at 21:44, Eli Zaretskii <[email-masked]> wrote:
>
>> > From: Paul Pogonyshev <[email-masked]>
>> > Date: Tue, 5 Sep 2023 20:54:54 +0200
>> >
>> > To reproduce:
>> >
>> > 1. Change current directory to a Git checkout (e.g. `~/git/emacs' or
>> something).
>> > 2. From the command line:
>> >
>> >        $ emacs --batch --eval "(progn (setf vc-git-program
>> \"git-is-not-installed\") (find-file-noselect
>> > \"whatever\"))"
>> >        Error: (file-missing "Searching for program" "No such file or
>> directory" "git-is-not-installed")
>> >
>> > Expected: Emacs is able to open the file, Git must not be essential.
>>
>> Emacs does open the file; what you see is not an error, it's a
>> message.  The code which tries to invoke Git runs with-demoted-errors,
>> so any error is converted to a simple message.  If you try this
>> variant of your command:
>>
>>   $ emacs --batch --eval "(progn (setf vc-git-program
>> \"git-is-not-installed\") (message \"%s\" (find-file-noselect \"README\")))"
>>
>> you will see:
>>
>>   Error: (file-missing "Searching for program" "No such file or
>> directory" "git-is-not-installed")
>>   README
>>
>> That "README" at the end means that find-file-noselect did read the
>> file into its buffer, and the error message is just a message.
>>
>> So if this somehow prevented you from doing something, please tell
>> more, or maybe the recipe needs more steps?
>>
>