6

When I launch Emacs24 (in an Ubuntu machine) I get an error message in the init procedure.

Warning (initialization): An error occurred while loading `/home/nivaca/.emacs':

But when I launch it with emacs --debug-init the debugger is not entered. How can I debug this problem?

  • Just to double check, do you have the same privileges when launching emacs with and without debugging ? It might be a launcher/terminal mismatch. Either way the *Messages* buffer should give you an idea of where the init barfs. – Vamsi Oct 10 '14 at 18:09
  • Yes, I believe so... But I will double check now. Anywhay, the *Messages* buffer gives me no clue. – NVaughan Oct 10 '14 at 18:12
  • 3
    What follows the final : in that warning message? If nothing, you might have uncovered an Emacs bug here. Presumably, that message is followed by some info about the error that occurred. – Drew Oct 10 '14 at 18:14
9

You do not enter the debugger from --debug-init in this case because the message is a warning, not an error message. IOW, in spite of the text in the warning message, which speaks of an "error", from Emacs's point of view, an error was not raised. (Or at least not an error that is respected by --debug-init -- see user-error.)

Suggestions for debugging:

  1. Recursively bisect your init file, to narrow down where the problem is. Do this by commenting-out 1/2 of it, then 3/4 of it, then 7/8, etc. You can use comment-region, with and without a plain prefix arg (C-u), to comment and uncomment regions of text.

  2. Add calls to message in your init file, to print information to let you know where the error occurs.

Use #1 especially if your init file is complex or it loads other libraries. #2 might suffice if your init file is simple and short.

1

You can use elisp-bug-hunter to automatically bisect your init file.

Automated error hunting

If your Emacs init file signals an error during startup, but you don’t know why, simply issue

M-x bug-hunter-init-file RET e

and The Bug Hunter will find it for you. Note that your init.el (or .emacs) must be idempotent for this to work.

Interactive hunt

If Emacs starts up without errors but something is not working as it should, invoke the same command, but choose the interactive option:

M-x bug-hunter-init-file RET i

The Bug Hunter will start a separate Emacs instance several times, and then it will ask you each time whether that instance presented the problem you have. After doing this about 5–12 times, you’ll be given the results.

  • Looks promissing. I'll give it a try. Thanks! – NVaughan Mar 28 at 14:50
0

Fixed it: there was a missing parenthesis in the .emacs file. However, the strange thing is that --debug-init couldn't spot it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.