@@ -1781,25 +1781,53 @@ RNAME is the name symbol of another existing layer."
17811781 ; ; installation
17821782 (when upkg-names
17831783 (spacemacs-buffer/set-mode-line " Installing packages..." t )
1784+ ; ; Prevent built-in org from being loaded when updating consult, for example.
1785+ (dolist (pkg-name configuration-layer--used-packages)
1786+ (when (and (package-built-in-p pkg-name)
1787+ (not (memq pkg-name upkg-names)))
1788+ (package-activate pkg-name)))
17841789 (let ((delayed-warnings-backup delayed-warnings-list))
17851790 (spacemacs-buffer/append
17861791 (format " Found %s new package(s) to install...\n "
17871792 not-inst-count))
17881793 (configuration-layer/retrieve-package-archives)
17891794 (setq installed-count 0 )
17901795 (spacemacs//redisplay)
1791- ; ; bootstrap and pre step packages first
1792- (dolist (pkg-name upkg-names)
1793- (let ((pkg (configuration-layer/get-package pkg-name)))
1794- (when (and pkg (memq (oref pkg step) '(bootstrap pre)))
1795- (setq installed-count (1+ installed-count))
1796- (configuration-layer//install-package pkg pkg-name installed-count not-inst-count))))
1797- ; ; then all other packages
1798- (dolist (pkg-name upkg-names)
1799- (let ((pkg (configuration-layer/get-package pkg-name)))
1800- (unless (and pkg (memq (oref pkg step) '(bootstrap pre)))
1801- (setq installed-count (1+ installed-count))
1796+
1797+ ; ; We sort the packages to be installed as follows:
1798+ ; ; 1. built-in packages
1799+ ; ; 2. bootstrap and pre packages
1800+ ; ; 3. all other packages
1801+ ; ; In particular, we install new versions of built-in packages first,
1802+ ; ; to avoid having the built-in package loaded instead of the new one
1803+ ; ; (for example when another package only depends on an older version;
1804+ ; ; or does not explicitly depend on it, but requires some of its
1805+ ; ; features somewhere).
1806+ ; ; FIXME Dependencies between built-in packages that should get updated
1807+ ; ; could still lead to errors due to built-in versions being loaded. For
1808+ ; ; example, if hypothetically, org (optionally) requires transient in
1809+ ; ; the future, we should take care to update transient before org.
1810+ (let* (built-in bootstrap-pre remaining
1811+ sorted-upkg-names)
1812+ (dolist (pkg-name upkg-names)
1813+ (let ((pkg (configuration-layer/get-package pkg-name)))
1814+ (push pkg-name
1815+ (cond ((package-built-in-p pkg-name)
1816+ built-in)
1817+ ((and pkg (or (eq (oref pkg step) 'bootstrap )
1818+ (eq (oref pkg step) 'pre )))
1819+ bootstrap-pre)
1820+ (t
1821+ remaining)))))
1822+ (setq sorted-upkg-names
1823+ (append (nreverse built-in)
1824+ (nreverse bootstrap-pre)
1825+ (nreverse remaining)))
1826+ (dolist (pkg-name sorted-upkg-names)
1827+ (cl-incf installed-count)
1828+ (let ((pkg (configuration-layer/get-package pkg-name)))
18021829 (configuration-layer//install-package pkg pkg-name installed-count not-inst-count))))
1830+
18031831 (spacemacs-buffer/append " \n " )
18041832 (unless init-file-debug
18051833 ; ; get rid of all delayed warnings when byte-compiling packages
0 commit comments