GNU bug report logs - #79356
31.0.50; 'C-x p r' fails when there are .gpg files EPA can't decrypt

Previous Next

Package: emacs;

Reported by: Sean Whitton <spwhitton <at> spwhitton.name>

Date: Sun, 31 Aug 2025 16:26:02 UTC

Severity: normal

Found in version 31.0.50

Fixed in version 31.1

Done: Sean Whitton <spwhitton <at> spwhitton.name>

To reply to this bug, email your comments to 79356 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org:
bug#79356; Package emacs. (Sun, 31 Aug 2025 16:26:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sean Whitton <spwhitton <at> spwhitton.name>:
New bug report received and forwarded. Copy sent to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org. (Sun, 31 Aug 2025 16:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; 'C-x p r' fails when there are .gpg files EPA can't decrypt
Date: Sun, 31 Aug 2025 17:25:27 +0100
X-debbugs-cc: monnier <at> iro.umontreal.ca

If you try to use 'C-x p r' in emacs.git it exits partway through
because insert-file-contents for etc/package-keyring.gpg cannot succeed.
EPA tries to decrypt the file but can't because it's a keyring.
It even suggests what the problem is:

--8<---------------cut here---------------start------------->8---
Error while decrypting with "/usr/bin/gpg2":

gpg: decrypt_message failed: Unexpected error

(File possibly not an encrypted file, but is perhaps a key ring file?)
--8<---------------cut here---------------end--------------->8---

The problem is a bit more general than just keyrings.  In other
repositories I work with there are encrypted files used as test suite
data.  I don't have the keys in my personal keyring; the keys too are
dummy test suite data, loaded up by the test suite.

In either case the presence of these files shouldn't make it impossible
to use 'C-x p r'.  So how about doing something like this:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/fileloop.el b/lisp/fileloop.el
index d7d2aa7e0d5..fd749353753 100644
--- a/lisp/fileloop.el
+++ b/lisp/fileloop.el
@@ -121,10 +121,17 @@ fileloop-next-file
         (kill-all-local-variables)
         (erase-buffer)
         (setq new next)
-        (condition-case nil
+        (condition-case err
             (insert-file-contents new nil)
           (file-missing
-           (fileloop-next-file novisit))))
+           (fileloop-next-file novisit))
+          (file-error
+           (unless
+               (and (equal (caddr err) "Can't decrypt")
+                    (y-or-n-p (substitute-quotes
+                               (format "Couldn't decrypt `%s'; skip it?"
+                                       (abbreviate-file-name new)))))
+             (signal (car err) (cdr err))))))
       new)))
 
 (defun fileloop-continue ()
--8<---------------cut here---------------end--------------->8---

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79356; Package emacs. (Mon, 01 Sep 2025 04:01:02 GMT) Full text and rfc822 format available.

Message #8 received at 79356 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: 79356 <at> debbugs.gnu.org
Subject: Re: bug#79356: 31.0.50; 'C-x p r' fails when there are .gpg files
 EPA can't decrypt
Date: Mon, 01 Sep 2025 00:00:01 -0400
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/fileloop.el b/lisp/fileloop.el
> index d7d2aa7e0d5..fd749353753 100644
> --- a/lisp/fileloop.el
> +++ b/lisp/fileloop.el
> @@ -121,10 +121,17 @@ fileloop-next-file
>          (kill-all-local-variables)
>          (erase-buffer)
>          (setq new next)
> -        (condition-case nil
> +        (condition-case err
>              (insert-file-contents new nil)
>            (file-missing
> -           (fileloop-next-file novisit))))
> +           (fileloop-next-file novisit))
> +          (file-error
> +           (unless
> +               (and (equal (caddr err) "Can't decrypt")
> +                    (y-or-n-p (substitute-quotes
> +                               (format "Couldn't decrypt `%s'; skip it?"
> +                                       (abbreviate-file-name new)))))
> +             (signal (car err) (cdr err))))))
>        new)))

The (equal (caddr err) "Can't decrypt") is rather hideous and brittle,
especially given that `fileloop` is a generic operation that shouldn't
know about EPA.

How 'bout we just prompt for all `file-error`s?  After all, the same
kind of reasoning applies to invalid .gz files, or files for which we
don't have read access, ...


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79356; Package emacs. (Mon, 01 Sep 2025 08:46:01 GMT) Full text and rfc822 format available.

Message #11 received at 79356 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 79356 <at> debbugs.gnu.org
Subject: Re: bug#79356: 31.0.50; 'C-x p r' fails when there are .gpg files
 EPA can't decrypt
Date: Mon, 01 Sep 2025 09:44:58 +0100
Hello,

On Mon 01 Sep 2025 at 12:00am -04, Stefan Monnier wrote:

> The (equal (caddr err) "Can't decrypt") is rather hideous and brittle,
> especially given that `fileloop` is a generic operation that shouldn't
> know about EPA.

Yes.

> How 'bout we just prompt for all `file-error`s?  After all, the same
> kind of reasoning applies to invalid .gz files, or files for which we
> don't have read access, ...

I realised after trying out my patch a bit that the prompting is a bit
annoying.  It's common to interrupt and then restart 'C-x p r'
operations but that means you get prompted over and over again for the
same files.

How about converting `file-error's into warnings?

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79356; Package emacs. (Mon, 01 Sep 2025 15:46:02 GMT) Full text and rfc822 format available.

Message #14 received at 79356 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: 79356 <at> debbugs.gnu.org
Subject: Re: bug#79356: 31.0.50; 'C-x p r' fails when there are .gpg files
 EPA can't decrypt
Date: Mon, 01 Sep 2025 11:45:49 -0400
>> How 'bout we just prompt for all `file-error`s?  After all, the same
>> kind of reasoning applies to invalid .gz files, or files for which we
>> don't have read access, ...
> I realised after trying out my patch a bit that the prompting is a bit
> annoying.  It's common to interrupt and then restart 'C-x p r'
> operations but that means you get prompted over and over again for the
> same files.
> How about converting `file-error's into warnings?

Fine by me (probably better if they're batched).


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79356; Package emacs. (Tue, 02 Sep 2025 12:44:01 GMT) Full text and rfc822 format available.

Message #17 received at 79356 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 79356 <at> debbugs.gnu.org
Subject: Re: bug#79356: 31.0.50; 'C-x p r' fails when there are .gpg files
 EPA can't decrypt
Date: Tue, 02 Sep 2025 13:42:50 +0100
[Message part 1 (text/plain, inline)]
Hello,

On Mon 01 Sep 2025 at 11:45am -04, Stefan Monnier wrote:

>>> How 'bout we just prompt for all `file-error`s?  After all, the same
>>> kind of reasoning applies to invalid .gz files, or files for which we
>>> don't have read access, ...
>> I realised after trying out my patch a bit that the prompting is a bit
>> annoying.  It's common to interrupt and then restart 'C-x p r'
>> operations but that means you get prompted over and over again for the
>> same files.
>> How about converting `file-error's into warnings?
>
> Fine by me (probably better if they're batched).

delay-warning seems to be sufficient to batch them up.
Let me know what you think of this.

-- 
Sean Whitton
[0001-fileloop-next-file-Convert-file-error-to-warnings.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79356; Package emacs. (Tue, 02 Sep 2025 14:01:03 GMT) Full text and rfc822 format available.

Message #20 received at 79356 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: 79356 <at> debbugs.gnu.org
Subject: Re: bug#79356: 31.0.50; 'C-x p r' fails when there are .gpg files
 EPA can't decrypt
Date: Tue, 02 Sep 2025 10:00:31 -0400
> From 056938803a5502f8427c6e97a74fa5b29a1d60c9 Mon Sep 17 00:00:00 2001
> From: Sean Whitton <spwhitton <at> spwhitton.name>
> Date: Tue, 2 Sep 2025 13:42:26 +0100
> Subject: [PATCH] fileloop-next-file: Convert file-error to warnings
>
> * lisp/fileloop.el (fileloop-next-file): Catch file-error and
> convert to a delayed warning (bug#79356).
> ---
>  lisp/fileloop.el | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/fileloop.el b/lisp/fileloop.el
> index d7d2aa7e0d5..903c5cca0a7 100644
> --- a/lisp/fileloop.el
> +++ b/lisp/fileloop.el
> @@ -121,10 +121,16 @@ fileloop-next-file
>          (kill-all-local-variables)
>          (erase-buffer)
>          (setq new next)
> -        (condition-case nil
> +        (condition-case err
>              (insert-file-contents new nil)
>            (file-missing
> -           (fileloop-next-file novisit))))
> +           (fileloop-next-file novisit))
> +          (file-error
> +           ;; See bug#79356 for discussion.
> +           (let ((msg (error-message-string err)))
> +             (unless (string-search new msg)
> +               (setq msg (format "%s, %s" msg new)))
> +             (delay-warning 'file-error msg :error)))))
>        new)))

Not sure "<msg>, <new>" is the best syntax (I'd have used "<new>:
<msg>", instead), but that looks good enough to me, thanks.


        Stefan





Reply sent to Sean Whitton <spwhitton <at> spwhitton.name>:
You have taken responsibility. (Tue, 02 Sep 2025 14:45:03 GMT) Full text and rfc822 format available.

Notification sent to Sean Whitton <spwhitton <at> spwhitton.name>:
bug acknowledged by developer. (Tue, 02 Sep 2025 14:45:03 GMT) Full text and rfc822 format available.

Message #25 received at 79356-done <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 79356-done <at> debbugs.gnu.org
Subject: Re: bug#79356: 31.0.50; 'C-x p r' fails when there are .gpg files
 EPA can't decrypt
Date: Tue, 02 Sep 2025 15:43:46 +0100
Version: 31.1

Hello,

On Tue 02 Sep 2025 at 10:00am -04, Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:

> Not sure "<msg>, <new>" is the best syntax (I'd have used "<new>:
> <msg>", instead), but that looks good enough to me, thanks.

I did the colon-separated format first but then I noticed that other
file-errors which were firing were putting it at the end.  I've switched
it back to the colon-separated format for now, anyway, and installed.
Thanks!

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79356; Package emacs. (Tue, 02 Sep 2025 17:06:02 GMT) Full text and rfc822 format available.

Message #28 received at 79356-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: 79356-done <at> debbugs.gnu.org
Subject: Re: bug#79356: 31.0.50; 'C-x p r' fails when there are .gpg files
 EPA can't decrypt
Date: Tue, 02 Sep 2025 13:05:17 -0400
>> Not sure "<msg>, <new>" is the best syntax (I'd have used "<new>:
>> <msg>", instead), but that looks good enough to me, thanks.
> I did the colon-separated format first but then I noticed that other
> file-errors which were firing were putting it at the end.

Hmm... I guess `error-message-string` uses ", <FILE>" when it's part of
the error object, indeed.  Maybe ", <new>" is a better choice after all?
As I said, I'm "not sure" which is the best syntax.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79356; Package emacs. (Thu, 04 Sep 2025 14:51:01 GMT) Full text and rfc822 format available.

Message #31 received at 79356-done <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 79356-done <at> debbugs.gnu.org
Subject: Re: bug#79356: 31.0.50; 'C-x p r' fails when there are .gpg files
 EPA can't decrypt
Date: Thu, 04 Sep 2025 15:50:36 +0100
Hello,

On Tue 02 Sep 2025 at 01:05pm -04, Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:

>>> Not sure "<msg>, <new>" is the best syntax (I'd have used "<new>:
>>> <msg>", instead), but that looks good enough to me, thanks.
>> I did the colon-separated format first but then I noticed that other
>> file-errors which were firing were putting it at the end.
>
> Hmm... I guess `error-message-string` uses ", <FILE>" when it's part of
> the error object, indeed.  Maybe ", <new>" is a better choice after all?
> As I said, I'm "not sure" which is the best syntax.

Me neither.  If either of us decides one is better than the other at
some point, we can change it over.

-- 
Sean Whitton




This bug report was last modified 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.