Subject: Re: bug#76264: [GNU ELPA] Use lisp-data-mode in generated *-pkg.el files

From: "Basil L. Contovounesios" <[email-masked]>
Date: Wed, 19 Mar 2025 22:32:41 +0100

Stefan Monnier [2025-03-19 11:00 -0400] wrote:

>> Here I see more than just a warning, in Emacs versions 24 through 27:
>>
>> 0. cd "$(mktemp -d)"
>> 1. HOME="$PWD" XDG_CONFIG_HOME="$PWD" emacs-27.2
>> 2. M-: (setq package-check-signature nil) RET
>> 3. M-x toggle-debug-on-error RET
>> 4. M-x package-install RET dash RET
>>
>> I attach backtraces from Emacs 24.5 and 27.2.
>
> Does it signal an error if you don't enable `toggle-debug-on-error`, or
> do we get a backtrace because of a `with-demoted-error` or some such?

AFAICT it's a real error, in the case of Emacs 27.2 (re)signalled from a
condition-case handler at the end of autoload-generate-file-autoloads:

    (error
     ;; Probably unbalanced parens in forward-sexp. In that case, the
     ;; condition is scan-error, and the signal data includes point
     ;; where the error was found; we'd like to convert that to
     ;; line:col, but line-number-at-pos gets the wrong line in batch
     ;; mode for some reason.
     ;;
     ;; At least this gets the file name in the error message; the
     ;; developer can use goto-char to get to the error position.
     (error "%s:0:0: error: %s: %s" file (car err) (cdr err)))

The example in the OP (installing dash from GNU ELPA) isn't so bad:
the user sees a scary error message, but after restarting Emacs dash
can be loaded without issue.

It can be worse, though:

0. cd "$(mktemp -d)"
1. HOME="$PWD" XDG_CONFIG_HOME="$PWD" emacs-27.2
2. M-: (setq package-check-signature nil) RET
3. M-: (setq package-archives '(("gnu" . "https://elpa.gnu.org/devel/"))) RET
4. M-x package-install RET hydra RET

This barfs while handling hydra's lv dependency, so hydra itself is
never installed.

-- 
Basil