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?
Asked
Active
Viewed 2,451 times
7

Mikael Springer
- 513
- 3
- 13
2 Answers
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.

casch-at
- 421
- 2
- 5
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.

glucas
- 20,563
- 1
- 54
- 84
-
1The 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 Mar 31 '17 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 ofuse-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 Mar 31 '17 at 17:57
(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: – malcook Nov 01 '19 at 17:43(when (not package-archive-contents) (package-refresh-contents))
before running this? – alper Oct 03 '20 at 01:41