Skip to content

Commit

Permalink
fixup! Add newly installed package to load path in exordium-force-elpa
Browse files Browse the repository at this point in the history
  • Loading branch information
pkryger committed Nov 26, 2024
1 parent 79a2b29 commit 634dd48
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions modules/init-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,30 @@ see Info node `(emacs) Package Installation'."
(use-package-pin-package package ,archive-name)
(condition-case-unless-debug err
(let ((package-install-upgrade-built-in t)
(load-path (cons (expand-file-name
(package-desc-full-name archive-desc)
package-user-dir)
load-path)))
(package-install-from-archive archive-desc)
t)
;; Ensure the newly installed package is in `load-path'
(with-load-path
(lambda (orig-fun &rest args)
(let ((pkg-dir (expand-file-name
(package-desc-full-name archive-desc)
package-user-dir)))
(if (or (member (file-name-as-directory pkg-dir) load-path)
(member (directory-file-name pkg-dir) load-path))
(apply orig-fun args)
(let ((load-path (cons pkg-dir load-path)))
(apply orig-fun args)))))))
(unwind-protect
(progn
;; `packgage-activate-1' calls
;; `package--reload-previously-loaded' before
;; adding the newly installed package directory to
;; `load-path'. Ensure the new files are visible.
(advice-add 'package--reload-previously-loaded
:around
with-load-path)
(package-install-from-archive archive-desc)
t)
(advice-remove 'package--reload-previously-loaded
with-load-path)))
(error
(display-warning 'use-package
(format "Failed to force ELPA installation %s: %s"
Expand Down

0 comments on commit 634dd48

Please sign in to comment.