Warning at startup: `package cl is deprecated`

Emacs emits this warning at startup, or shortly afterwards:

package cl is deprecated

3 Likes

cl is a library included with Emacs. It was deprecated in Emacs 27 and replaced by cl-lib.

The first time something, somewhere, loads cl at runtime you will see this warning. It is harmless, but mostly* unavoidable. Simply ignore it.

Doom does not use cl, but a number of third-party packages do. Until they update this warning is here to stay — Emacs offers no reliable way to suppress it.

“Mostly” unavoidable?

The warning is emitted by the function do-after-load-evaluation. You could advise it, to silence it:

;;; add to $DOOMDIR/config.el
(defadvice! fixed-do-after-load-evaluation (abs-file)
  :override #'do-after-load-evaluation
  (dolist (a-l-element after-load-alist)
    (when (and (stringp (car a-l-element))
               (string-match-p (car a-l-element) abs-file))
      (mapc #'funcall (cdr a-l-element))))
  (run-hook-with-args 'after-load-functions abs-file))

But be warned, this is a hack, and may suddenly break after an Emacs update. Use it at your own risk.

How packages need to change

The problem is simple. The cl library is being loaded at runtime. i.e. There’s a (require 'cl) in some package somewhere. M-x doom/help-search-load-path may help you locate them. Their maintainers may need to be reminded to do one of:

  • Replace (require 'cl) with (require 'cl-lib) and prefix all references to cl macros with cl- (e.g. find → cl-find, remove-if → cl-remove-if, etc). The cl-libify library can automate this.

  • Wrap (require 'cl) in (eval-when-compile ...):

    (eval-when-compile
      (require 'cl))
    

    This way, the package is only loaded at compile time (the only time it’s really needed).

9 Likes