Skip to content

Commit

Permalink
[try] use package-transaction for elpa enforcment
Browse files Browse the repository at this point in the history
  • Loading branch information
pkryger committed Nov 26, 2024
1 parent cb01e18 commit 87db61a
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions modules/init-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -136,34 +136,10 @@ 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)
;; 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' and then
;; adds the newly installed package directory to
;; `load-path'. This however may be not sufficient
;; when some files `requires' files from the
;; package. Ensure the new files are visible for
;; the latter call, and allow the original
;; `load-path' to be updated by the former.
(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)))
(transaction (package-compute-transaction (list archive-desc)
(package-desc-reqs pkg))))
(package-download-transaction transaction)
(package--quickstart-maybe-refresh))
(error
(display-warning 'use-package
(format "Failed to force ELPA installation %s: %s"
Expand Down

0 comments on commit 87db61a

Please sign in to comment.