Emacs doesn't want to autoremove packages from elpa because some of them are system packages.

How can I launch autoremove ignoring system packages?

Error enabling Flyspell mode: (stringp nil)106 packages will be deleted: notmuch, ws-butler, winum, which-key, volatile-highlights, vi-tilde-fringe, uuidgen, use-package, undo-tree, toc-org, spinner, spaceline, smartparens, s, restart-emacs, request, rainbow-delimiters, projectile, powerline, popwin, popup, persp-mode, pcre2el, parent-mode, paradox, packed, org-bullets, open-junk-file, neotree, move-text, macrostep, lorem-ipsum, linum-relative, link-hint, info+, indent-guide, iedit, hydra, hungry-delete, hl-todo, highlight-parentheses, highlight-numbers, highlight-indentation, highlight, hide-comnt, help-fns+, helm-themes, helm-swoop, helm-projectile, helm-mode-manager, helm-make, helm-flx, helm-descbinds, helm-core, helm-ag, helm, goto-chg, google-translate, golden-ratio, flx-ido, flx, fill-column-indicator, fancy-battery, f, eyebrowse, expand-region, exec-path-from-shell, evil-visualstar, evil-visual-mark-mode, evil-unimpaired, evil-tutor, evil-surround, evil-search-highlight-persist, evil-numbers, evil-nerd-commenter, evil-mc, evil-matchit, evil-lisp-state, evil-indent-plus, evil-iedit-state, evil-exchange, evil-escape, evil-ediff, evil-args, evil-anzu, evil, eval-sexp-fu, elisp-slime-nav, dumb-jump, diminish, define-word, column-enforce-mode, clean-aindent-mode, bind-map, bind-key, avy, auto-highlight-symbol, auto-compile, auctex, async, anzu, aggressive-indent, adaptive-wrap, ace-window, ace-link, ace-jump-helm-line, proceed? (y or n) y

package-delete: Package ‘notmuch-0.26.2’ is a system package, not deleting

1 Answer 1


I would look at these two. Maybe you could modify package-selected-packages before running package-autoremove.

package-autoremove is an interactive autoloaded compiled Lisp function
in ‘package.el’.


Remove packages that are no more needed.

Packages that are no more needed by other packages in
‘package-selected-packages’ and their dependencies
will be deleted.

[back]  [forward]

package-selected-packages is a variable defined in ‘package.el’.
Its value is
(abyss-theme company-irony company-irony-c-headers flycheck flycheck-irony irony rainbow-delimiters gandalf-theme alect-themes basic-mode elpy org-ac vbasense psvn omnisharp)

Original value was nil

Store here packages installed explicitly by user.
This variable is fed automatically by Emacs when installing a new package.
This variable is used by ‘package-autoremove’ to decide
which packages are no longer needed.
You can use it to (re)install packages on other machines
by running ‘package-install-selected-packages’.

To check if a package is contained in this list here, use
‘package--user-selected-p’, as it may populate the variable with
a sane initial value.

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 25.1 of Emacs.


Here is the function definition in package.el

(defun package-autoremove ()
  "Remove packages that are no more needed.

Packages that are no more needed by other packages in
`package-selected-packages' and their dependencies
will be deleted."
  ;; If `package-selected-packages' is nil, it would make no sense to
  ;; try to populate it here, because then `package-autoremove' will
  ;; do absolutely nothing.
  (when (or package-selected-packages
              "`package-selected-packages' is empty! Really remove ALL packages? ")))
    (let ((removable (package--removable-packages)))
      (if removable
          (when (y-or-n-p
                 (format "%s packages will be deleted:\n%s, proceed? "
                   (length removable)
                   (mapconcat #'symbol-name removable ", ")))
            (mapc (lambda (p)
                    (package-delete (cadr (assq p package-alist)) t))
        (message "Nothing to autoremove")))))
  • The patch in Bug#27822 should help (it will be included in Emacs 26.2).
    – npostavs
    Commented Sep 5, 2018 at 23:23

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.