[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59707: 29.0.50; Seeking a more robust `package-quickstart'
From: |
Matt Armstrong |
Subject: |
bug#59707: 29.0.50; Seeking a more robust `package-quickstart' |
Date: |
Wed, 30 Nov 2022 11:13:52 -0800 |
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.
>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