Subject: Re: bug#63260: 29.0.90; Regression installing/activating packages without autoloads

From: Robert Pluim <[email-masked]>
Date: Fri, 05 May 2023 08:36:51 +0200

>>>>> On Thu, 04 May 2023 18:28:47 +0200, Basil Contovounesios <[email-masked]> said:

    Basil> Robert Pluim [2023-05-04 17:15 +0200] wrote:
    >>>>>>> On Thu, 04 May 2023 12:15:15 +0200, Basil Contovounesios via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email-masked]> said:
    >> 
    Bug> This change:
    Basil> Prevent generating empty autoload files
    Basil> dd21003878d 2023-04-30 18:42:58 +0200
    Basil> https://git.sv.gnu.org/cgit/emacs.git/commit/?id=dd21003878d
    Basil> seems to have reintroduced the following issue:
    Basil> https://lists.gnu.org/r/emacs-devel/2022-06/msg00563.html
    Basil> First start Emacs 29 (or 30) with a clean slate:
    Basil> $ cd "$(mktemp --directory)"
    Basil> $ export HOME="${PWD}" XDG_CONFIG_HOME="${PWD}/.config"
    Basil> $ emacs
    Basil> Then try to install the sicp package (which lacks autoloads) from MELPA:
    Basil> 0. C-x b RET
    Basil> 1. (setq package-archives '(("melpa" . "https://melpa.org/packages/")))
    Basil> C-x C-e
    Basil> 2. M-x package-install RET sicp RET
    Basil> 3. C-h e
    Basil> 4. C-M-S-v
    >> 
    >> Only when `package-quickstart' is non-nil, right?

    Basil> No, this is in an empty user-emacs-directory, i.e. with the default
    Basil> package-quickstart = nil.  Besides, package-quickstart does not come
    Basil> into play during package-install AFAICT.

Right. My testing was faulty

    Basil> This does not address the file-missing error during package activation,
    Basil> but it allows a subsequent package-quickstart-refresh to complete
    Basil> (albeit with a warning in a *Compile-Log*):

The file-missing error is expected, no? Thatʼs why the autoloads
loading is wrapped in `with-demoted-errors'. Although if the message bothers
you, I guess we could check `file-exists-p' for it.

    Basil>   Compiling file /tmp/tmp.6cdF8paE0K/.emacs.d/package-quickstart.el
    Basil>                  at Thu May  4 18:24:07 2023
    Basil>   Entering directory ‘/tmp/tmp.6cdF8paE0K/.emacs.d/’
    Basil>   package-quickstart.el:4:2: Warning: Empty let body

    Basil> due to the following generated contents of package-quickstart-file:

    Basil>   (let ((load-true-file-name nil)(load-file-name nil))
    Basil>   )

Iʼd claim ENOCOFFEE for the last patch, but it was not the morning :-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 0919ce34448..4b488281b78 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -4491,11 +4491,11 @@ package-quickstart-refresh
       (insert ";;; Quickstart file to activate all packages at startup  -*- lexical-binding:t -*-\n")
       (insert ";; ¡¡ This file is autogenerated by `package-quickstart-refresh', DO NOT EDIT !!\n\n")
       (dolist (pkg package--quickstart-pkgs)
-        (let* ((file
-                ;; Prefer uncompiled files (and don't accept .so files).
-                (let ((load-suffixes '(".el" ".elc")))
-                  (locate-library (package--autoloads-file-name pkg))))
-               (pfile (prin1-to-string file)))
+        (when-let* ((file
+                     ;; Prefer uncompiled files (and don't accept .so files).
+                     (let ((load-suffixes '(".el" ".elc")))
+                       (locate-library (package--autoloads-file-name pkg))))
+                    (pfile (prin1-to-string file)))
           (insert "(let ((load-true-file-name " pfile ")\
 \(load-file-name " pfile "))\n")
           (insert-file-contents file)

Robert
--