From 24164f48692f25edd2d607c5f7917d58318898ab Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 16:16:58 -0400 Subject: [PATCH] Disable use-package's :ensure t property by default Many packages recommend setting up their packages with something like: (use-package PACKAGE :ensure t ...) New users will frequently copy these into their config, then experience long startup times or a cryptic error about the package failing to install. This is because `:ensure t`, by default, uses package.el (Emacs' built-in package manager) to check for and install packages, but Doom doesn't use package.el, it uses straight.el. So we disable `:ensure`. On the other hand, if the user has loaded `package` by hand, then we should assume that they know what they're doing, and restore the old behavior. --- core/core-modules.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/core-modules.el b/core/core-modules.el index c866e1289..b50fdd33c 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -254,6 +254,17 @@ This value is cached. If REFRESH-P, then don't use the cached value." ;; Macros are already fontified, no need for this (font-lock-remove-keywords 'emacs-lisp-mode use-package-font-lock-keywords) + ;; A common mistake for new users is that they inadvertantly try to install + ;; their 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. + (setq use-package-ensure-function #'ignore) + ;; ...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))) + ;; We define :minor and :magic-minor from the `auto-minor-mode' package here ;; so we don't have to load `auto-minor-mode' so early. (dolist (keyword '(:minor :magic-minor))