7

I'm using use-package in my init.el for all my package installations and configuration. I thought specifying :ensure t in use-package would make sure I always have the latest versions installed. But when I did M-x package-list-packages the minibuffer tells me I have a number of package updates waiting. Isn't it enough to specify :ensure t in use-package, do I have to manually check for and install updates using M-x package-list-packages? What is the best way to handle updates when using use-package?

2 Answers 2

7

The :ensure option in use-package does not automatically keep packages up to date. It ensures that the package is installed. This might be useful if you pull your Emacs config on to a new machine (or are using it across several machines), because when you start up all your required packages would get installed.

You'll still need to deal with installing updates.

2
  • 1
    The reason I've heard as to why that's the case is because updating packages can break them, so it would regress in functionality.
    – zck
    Commented Mar 31, 2017 at 16:58
  • 1
    @zck I think it's more that use-package is meant to provide a quick startup and checking for updates would be slow. Also, the author of use-package doesn't use package.el packages, any related features (like :ensure) were tacked on afterwards by other users. In the original design, all packages are considered optional, your init.el just skips configuration of missing packages.
    – npostavs
    Commented Mar 31, 2017 at 17:57
14

I use auto-package-update to automatically update packages.

(use-package auto-package-update
   :ensure t
   :config
   (setq auto-package-update-delete-old-versions t
         auto-package-update-interval 4)
   (auto-package-update-maybe))

With that setup, packages will be updated every 4 days, and the old packages will be removed.

3
  • 1
    You might want to add this as an answer here: emacs.stackexchange.com/questions/31872/…
    – glucas
    Commented Apr 3, 2017 at 18:10
  • It appears to me that the call to ` (auto-package-update-maybe)` is not the value of one of use-package's keyword options. Should it perhaps be wrapped in a progn as part of the :config, like this: ``` (use-package auto-package-update :ensure t :config (progn (setq auto-package-update-delete-old-versions t auto-package-update-interval 4) (auto-package-update-maybe))) ```
    – malcook
    Commented Nov 1, 2019 at 17:43
  • should I do (when (not package-archive-contents) (package-refresh-contents)) before running this?
    – alper
    Commented Oct 3, 2020 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.