42

I'm using use-package to install and configure packages (most of these packages are in melpa). Is there a clean automated way of keeping all these packages up-to-date ?

If not, what is the best work flow in this case ?

Note: A very similar question here with an answer, but I wanted a clarification on "You'll still need to deal with installing updates". I could not comment on the answer for clarification as I do not have enough reputation.

7 Answers 7

41

I just do this manually: run list-packages hit Uto mark available upgrades, then review to decide if there are any I don't want to pick up. Then x to upgrade. I do this pretty regularly, and often check what's new at the same time. I've got a couple tweaks to simplify this (see below).

I suspect upgrading could be automated, but you do want to consider the case where an update breaks something and you need to back it out and then prevent your automated updater from just installing it again.

Some package menu tweaks:

(defun package-menu-find-marks ()
  "Find packages marked for action in *Packages*."
  (interactive)
  (occur "^[A-Z]"))

;; Only in Emacs 25.1+
(defun package-menu-filter-by-status (status)
  "Filter the *Packages* buffer by status."
  (interactive
   (list (completing-read
          "Status: " '("new" "installed" "dependency" "obsolete"))))
  (package-menu-filter (concat "status:" status)))

(define-key package-menu-mode-map "s" #'package-menu-filter-by-status)
(define-key package-menu-mode-map "a" #'package-menu-find-marks)

With this I can use s new to just see what packages are newly available. And after hitting U to mark upgrades I can hit a for an occur buffer list of the ones that were marked, in case I want to dig in to details of what changed etc.

UPDATED: Emacs 28 added new package menu commands to filter the package list in various ways, replacing the need for the custom commands above. Use /-? to see the available package-menu-filter-* bindings.

7
  • Thanks, the questions is primarily answered. a worked for finding out marked packages. However, s installed or any of the other remaining three statuses returns an empty list. Commented Apr 2, 2017 at 14:05
  • What version of Emacs are you using?
    – glucas
    Commented Apr 2, 2017 at 15:03
  • I'm using 24.5.1 Commented Apr 2, 2017 at 22:58
  • Ah ok. I checked and the package-menu-filter command is new in 25.1, so that command won't work for you.
    – glucas
    Commented Apr 3, 2017 at 0:20
  • 1
    These tweaks are now unnecessary, you can filter packages in recent Emacs versions with the / command. See here
    – kotchwane
    Commented Apr 8, 2022 at 16:00
19

You can use auto-package-update to automatically update packages.

Copied from my other post (https://emacs.stackexchange.com/a/31903/9972)

(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.

2
  • Doesn't Emacs require to be restarted after a packages update (at least for some packages)? Commented Dec 4, 2020 at 9:00
  • 2
    True, but if you put this peace of code before the other packages get loaded, you should be fine.
    – casch-at
    Commented Jan 17, 2021 at 17:12
6

There is a highly recommended package called paradox that extends package management commands. Read more from https://github.com/Malabarba/paradox

(use-package paradox
  :init
  (setq paradox-github-token t)
  (setq paradox-execute-asynchronously t)
  (setq paradox-automatically-star t))

This setup feeds package usage statistics back to system using a separately set github token and updates packages in the background when you manually run the command paradox-upgrade-packages bound to your keys of choice.

Read the inline documentation of the variable paradox-github-token on how to set it up.

3

In Emacs 29.1, you can use M-x package-menu-filter-upgradable to display packages with updates available. M-x package-upgrade-all will install the updates.

0

Try epm to keep update process clean.

cf. https://github.com/xuchunyang/epm

It can run update process within emacs batch process, without loading normal init.el settings.

0

Just enter list-packages and pres SHIFT+U. It will mark all installed packages for an update.

1
  • 1
    It's arguably not fully automatic.
    – JeanPierre
    Commented Sep 29, 2019 at 7:27
0

Emacs package update sometimes fails.

If package installation is automated using use-package, delete the .emacs.d/elpa directory and reinstall the package.

good luck

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.