From 0ec2a7408eb248eef21c0a431eaf9c23cd5e99d3 Mon Sep 17 00:00:00 2001 From: Matt Armstrong 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