38

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.

Jaagrit Sapana
  • 485
  • 1
  • 4
  • 5

6 Answers6

36

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.

glucas
  • 20,175
  • 1
  • 51
  • 83
18

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.

cslux
  • 421
  • 2
  • 5
5

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.

Heikki
  • 2,961
  • 11
  • 18
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.

lurdan
  • 1,071
  • 7
  • 11
0

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

slk500
  • 461
  • 2
  • 14
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

Muihlinn
  • 2,576
  • 1
  • 14
  • 22