From eccde78741cf7b319e052f44b208a251e17f92e8 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 3 Mar 2026 06:57:35 -0500 Subject: [PATCH] fix(use-package): use-package-ensure-function Doom is configured to ignore :ensure in `use-package`, unless the user has manually called `(package-initialize)` -- in which case, we assume the user genuinely *wants* to use package.el, or some reason. --- modules/config/use-package/init.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/config/use-package/init.el b/modules/config/use-package/init.el index 78c01a773..d3cecdd42 100644 --- a/modules/config/use-package/init.el +++ b/modules/config/use-package/init.el @@ -24,14 +24,14 @@ ;; packages with package.el, by copying over old `use-package' declarations with ;; an :ensure t property. Doom doesn't use package.el, so this will throw an ;; error that will confuse beginners, so we disable `:ensure'. -(setq use-package-ensure-function - (lambda (name &rest _) - (message "Ignoring ':ensure t' in '%s' config" name))) -;; ...On the other hand, if the user has loaded `package', then we should assume -;; they know what they're doing and restore the old behavior: -(add-transient-hook! 'package-initialize - (when (eq use-package-ensure-function #'ignore) - (setq use-package-ensure-function #'use-package-ensure-elpa))) +(defun +use-package--ignore-ensure-maybe-fn (name &rest args) + ;; ...On the other hand, if the user has loaded `package', then we should + ;; assume they know what they're doing and restore the old behavior: + (if (bound-and-true-p package--initialized) + (apply #'use-package-ensure-elpa name args) + (doom-log "Ignoring ':ensure t' in '%s' config" name) + (not (memq name doom-disabled-packages)))) +(setq use-package-ensure-function #'+use-package--ignore-ensure-maybe-fn) (with-eval-after-load 'use-package-core ;; `use-package' adds syntax highlighting for the `use-package' macro, but