On startup I'm getting this message:
Eager macro-expansion failure: (wrong-number-of-arguments (3 . 3) 2)
How can I find whats causing the warning? --debug-init
doesn't do anything in this case as it does with many other errors.
On startup I'm getting this message:
Eager macro-expansion failure: (wrong-number-of-arguments (3 . 3) 2)
How can I find whats causing the warning? --debug-init
doesn't do anything in this case as it does with many other errors.
This error message comes from the macroexp.el
function, internal-macroexpand-for-load
. It should go a little something like this (I have simplified the t
portion of a cond
, where most code will end up):
(condition-case err
(let ((macroexp--pending-eager-loads
(cons load-file-name macroexp--pending-eager-loads)))
(if full-p
(macroexpand-all form)
(macroexpand form)))
(error
;; Hopefully this shouldn't happen thanks to the cycle detection,
;; but in case it does happen, let's catch the error and give the
;; code a chance to macro-expand later.
(message "Eager macro-expansion failure: %S" err)
form))
As you can see, it essentially swallows up the error. It's pretty hard to get at this, since the function will simply note the problem, eat the error, and return the original form
. There is hope, though: debug-on-signal
plus debug-on-error
.
The error message you showed indicates that err
in this condition-case
is a signal: wrong-number-of-arguments
. So if we instruct Emacs to first debug on any errors (by doing something like (setq debug-on-error t)
), and then on any signal (with (setq debug-on-signal t)
), we end up getting into the debugger with the stack trace ready to examine. If you don't mark debug-on-error
, nothing will happen, so you need to have bot set to t
.
FWIW, I reproduced the behavior you mentioned with this obviously wrong code:
(defun bad-defun (str)
(rx (eval (substring str 1))))
...and M-x evaluate-buffer
, then observed that I got a stack trace after executing M-: (setq debug-on-signal t)
and M-: (setq debug-on-error t)
, so some similar combination may work for you. Perhaps setting it at the top of your initialization file, or passing it on the Emacs command line.
Caveat: Once you encounter the error, you should probably turn off debug-on-signal
, because it will pop up when you are in the middle of something, any time a function reports an error or warning!