unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Matt Armstrong <matt@rfc20.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 59707@debbugs.gnu.org
Subject: bug#59707: 29.0.50; Seeking a more robust `package-quickstart'
Date: Wed, 30 Nov 2022 11:13:52 -0800	[thread overview]
Message-ID: <87fse08dcf.fsf@rfc20.org> (raw)
In-Reply-To: <87cz95rnhf.fsf@rfc20.org>

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

Matt Armstrong <matt@rfc20.org> writes:

>>> 1) Harden Emacs such that signaled errors from
>>> "package-quickstart.elc" don't prevent startup (but are somehow
>>> saved and logged, maybe as warnings?).
>>
>> Agreed.  I suspect it should also do things like delete the `.elc`
>> file (and/or the `.el` file), or at least suggest doing it, so as to
>> help diagnose/circumvent the problem.
>
> Ok, let's keep it on the list of possibilities.

This (attached) approach seems to work in my manual testing.  If you
like the general idea I can polish it off (try to make a test, etc.).

One thing that bothers me: because I fall back to
`package--activate-all' even package that successfully activate in the
quickstart file can have their activation code run twice, and they
aren't necessarily idempotent operations.  Do you think this is a
significant problem?

One possibility is to update `package-activated-list' and
`Info-directory-list' incrementally in the quickstart file, so any
signaled errors leave `package-activated-list' mostly-correct.  This
way, `package--activate-all' will attempt to activate only one package
twice -- the one that signaled from the quickstart file.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-package-activate-all-resilient-to-quickload-err.patch --]
[-- Type: text/x-diff, Size: 2451 bytes --]

From 0ec2a7408eb248eef21c0a431eaf9c23cd5e99d3 Mon Sep 17 00:00:00 2001
From: Matt Armstrong <matt@rfc20.org>
Date: Wed, 30 Nov 2022 10:56:59 -0800
Subject: [PATCH] Make `package-activate-all' resilient to quickload errors.

If `package-activate-all' fails Emacs fails to start, so if
quickloading fails fall back to per-package activation.  Note that
per-package activation already has logic to report package level
actiation errors with `message' and continue.
---
 lisp/emacs-lisp/package.el | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 8d44fae30a..95921256d6 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1714,16 +1714,23 @@ package-activate-all
                    package-quickstart-file))))
     ;; The quickstart file presumes that it has a blank slate,
     ;; so don't use it if we already activated some packages.
-    (if (and qs (not (bound-and-true-p package-activated-list)))
-        ;; Skip load-source-file-function which would slow us down by a factor
-        ;; 2 when loading the .el file (this assumes we were careful to
-        ;; save this file so it doesn't need any decoding).
-        (let ((load-source-file-function nil))
-          (unless (boundp 'package-activated-list)
-            (setq package-activated-list nil))
-          (load qs nil 'nomessage))
-      (require 'package)
-      (package--activate-all)))))
+    (or (and qs (not (bound-and-true-p package-activated-list))
+             ;; Skip load-source-file-function which would slow us
+             ;; down by a factor 2 when loading the .el file (this
+             ;; assumes we were careful to save this file so it
+             ;; doesn't need any decoding).
+             (let ((load-source-file-function nil))
+               (unless (boundp 'package-activated-list)
+                 (setq package-activated-list nil))
+               (condition-case err
+                   (load qs nil 'nomessage)
+                 ;; If quickstart activation fails fall through to
+                 ;; `package--activate-all' activation.
+                 (error (message "Error loading %s: %s"
+                                 qs (error-message-string err))))))
+        (progn
+          (require 'package)
+          (package--activate-all))))))
 
 ;;;###autoload
 (defun package--activate-all ()
-- 
2.35.1


      parent reply	other threads:[~2022-11-30 19:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30  0:14 bug#59707: 29.0.50; Seeking a more robust `package-quickstart' Matt Armstrong
2022-11-30  2:37 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-30  5:59   ` Matt Armstrong
2022-11-30 13:11     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-30 19:13     ` Matt Armstrong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fse08dcf.fsf@rfc20.org \
    --to=matt@rfc20.org \
    --cc=59707@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).