From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Paul Pogonyshev Newsgroups: gmane.emacs.bugs Subject: bug#65763: Error opening a file from a Git working directory if Git is not installed Date: Tue, 5 Sep 2023 22:14:15 +0200 Message-ID: References: <831qfc4d7h.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000112f750604a2468a" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30597"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65763@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 05 22:16:09 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qdcT3-0007nk-Fq for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 05 Sep 2023 22:16:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdcRy-00052E-LP; Tue, 05 Sep 2023 16:15:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qdcRx-00050g-MB for bug-gnu-emacs@gnu.org; Tue, 05 Sep 2023 16:15:01 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qdcRx-000393-AD for bug-gnu-emacs@gnu.org; Tue, 05 Sep 2023 16:15:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qdcRx-0005rJ-UM for bug-gnu-emacs@gnu.org; Tue, 05 Sep 2023 16:15:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Pogonyshev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Sep 2023 20:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65763 X-GNU-PR-Package: emacs Original-Received: via spool by 65763-submit@debbugs.gnu.org id=B65763.169394487622472 (code B ref 65763); Tue, 05 Sep 2023 20:15:01 +0000 Original-Received: (at 65763) by debbugs.gnu.org; 5 Sep 2023 20:14:36 +0000 Original-Received: from localhost ([127.0.0.1]:59542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdcRX-0005qN-LC for submit@debbugs.gnu.org; Tue, 05 Sep 2023 16:14:36 -0400 Original-Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]:59460) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdcRV-0005qB-N8 for 65763@debbugs.gnu.org; Tue, 05 Sep 2023 16:14:34 -0400 Original-Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-500913779f5so4920441e87.2 for <65763@debbugs.gnu.org>; Tue, 05 Sep 2023 13:14:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693944867; x=1694549667; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=d+Zid8tklD0Vq2m7Y1qHKgC5q0G+0QWhLe6uXMzDgqE=; b=GVMVhYbahr9s+Z1ubVl4V6uHn6MkOj0v2SGUDUNIVyKtE0wIkvP9AFEdWQ/VYnel90 sZa7/bLD5KSLf+lsN8sTyXwBcuUbNayksAiOBUEpP499dL8DJz590fRHoV+2beJRdBB7 2G2mFmu0xR8KN2eiGbDx7ghGQ/pw8Tp1TB2wdaMnu0vQSgk6Fxuvhf/+DVyrBpc8RNeu 98tuttSPQAS6ZrjEB7l66sOfhBIWKmhiIEDWw4GxxryoQ4tDtNQpEeOvcHyeM76vT7Nv P3XYYwP3hb+GguS1Pbmcnc1vQtfi7PvqKmY1q3KH8lQaohfsJbWLo3A6B4K1rOvd3G3R xPTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693944867; x=1694549667; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d+Zid8tklD0Vq2m7Y1qHKgC5q0G+0QWhLe6uXMzDgqE=; b=klmXmrnYVepfLcaf2t7vHukZrMHtq61/79J8ZTK6wSfdBFQd3M3rtpy/Ce0X9iNkqv fMjMWMKZ1OzTGq28asrsHKbZqGxFdb/c6xzXzf/AVz2GIFUZMsUcUpAJICB0rTBisBAR GZiXpWQraTbgJrOmTCVrhMbMmBPJrzvMP0l6m8uqF4Dv6J7rvLHsp8Fq5IM/gsHAk+IG +LQRljLH3vO2CRtzK4aUiyb/pyccTg5hgmaysFBsdcQrGYgAvw+lQUdpg1gp+nHPiVcd or7OXwODsGe+fcuWDDlynyTIE9xCiWQXQXi43k6weqZGdEHE/JFQlVhoSSbQ0/m/tqKS 1JLg== X-Gm-Message-State: AOJu0YyRWBludN8ucPeUP8CRdJIIhigFA2x/Th3lHrh5KrDbYb8xXlIj vC9nqrMQivcRz5g9GcLlnZCuNgI2rjvRwSfilA== X-Google-Smtp-Source: AGHT+IEEDgId3wslV+Go8FvCypuJbZn0c9BkiOuBI+30aj5KqFSpQZT+Our4TSJpbwgjUdbop+2wUJN14alEi2X38As= X-Received: by 2002:a05:6512:2083:b0:4fe:179a:18d2 with SMTP id t3-20020a056512208300b004fe179a18d2mr664065lfr.21.1693944867007; Tue, 05 Sep 2023 13:14:27 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:269401 Archived-At: --000000000000112f750604a2468a Content-Type: text/plain; charset="UTF-8" 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 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) #)(Git) > mapc(#f(compiled-function (b) #) (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(# "~/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 wrote: > >> > From: Paul Pogonyshev >> > 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? >> > --000000000000112f750604a2468a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ah, `debug-on-error' makes `with-demoted-errors' n= ot demote it.

It seems in my case `debug-on-error' i= s 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 <= ;pogonyshev@gmail.com> 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\&quo= t;))"
Debugger entered--Lisp error: (file-missing "Searching f= or program" "No such file or directory" "git-is-not-ins= talled")
=C2=A0 call-process("git-is-not-installed" nil (= t nil) nil "--no-pager" "ls-files" "-c" "= ;-z" "--" "whatever")
=C2=A0 process-file("= ;git-is-not-installed" nil (t nil) nil "--no-pager" "ls= -files" "-c" "-z" "--" "whatever&qu= ot;)
=C2=A0 vc-git--call((t nil) "ls-files" "-c" &qu= ot;-z" "--" "whatever")
=C2=A0 vc-git--out-ok(&= quot;ls-files" "-c" "-z" "--" "what= ever")
=C2=A0 vc-git-registered("/home/paul/eldev/whatever&quo= t;)
=C2=A0 vc-git-registered("/home/paul/eldev/whatever")
= =C2=A0 vc-call-backend(Git registered "/home/paul/eldev/whatever"= )
=C2=A0 #f(compiled-function (b) #<bytecode 0x15a622e462a366fe>)(= Git)
=C2=A0 mapc(#f(compiled-function (b) #<bytecode 0x15a622e462a366= fe>) (RCS CVS SVN SCCS SRC Bzr Git Hg))
=C2=A0 vc-registered("/h= ome/paul/eldev/whatever")
=C2=A0 vc-backend("/home/paul/eldev/= whatever")
=C2=A0 vc-refresh-state()
=C2=A0 run-hooks(find-file-= hook)
=C2=A0 after-find-file(t t)
=C2=A0 find-file-noselect-1(#<bu= ffer whatever> "~/eldev/whatever" nil nil "~/eldev/whatev= er" nil)
=C2=A0 find-file-noselect("whatever")
=C2=A0 = (let ((debug-on-error t)) (setf vc-git-program "git-is-not-installed&q= uot;) (find-file-noselect "whatever"))
=C2=A0 command-line-1((= "--eval" "(let ((debug-on-error t)) (setf vc-git-program \&q= uot;gi..."))
=C2=A0 command-line()
=C2=A0 normal-top-level()
=

Paul

On Tue, 5 Sept 2023 at 21:44, Eli Zaretskii &= lt;eliz@gnu.org> w= rote:
> From:= Paul Pogonyshev <pogonyshev@gmail.com>
> 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:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 $ emacs --batch --eval "(progn (setf v= c-git-program \"git-is-not-installed\") (find-file-noselect
> \"whatever\"))"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 Error: (file-missing "Searching for pr= ogram" "No such file or directory" "git-is-not-installe= d")
>
> 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.=C2=A0 The code which tries to invoke Git runs with-demoted-errors,=
so any error is converted to a simple message.=C2=A0 If you try this
variant of your command:

=C2=A0 $ emacs --batch --eval "(progn (setf vc-git-program \"git-= is-not-installed\") (message \"%s\" (find-file-noselect \&qu= ot;README\")))"

you will see:

=C2=A0 Error: (file-missing "Searching for program" "No such= file or directory" "git-is-not-installed")
=C2=A0 README

That "README" at the end means that find-file-noselect did read t= he
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?
--000000000000112f750604a2468a--