10

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?

3
  • 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
    Commented Oct 10, 2014 at 18:09
  • Yes, I believe so... But I will double check now. Anywhay, the *Messages* buffer gives me no clue.
    – NVaughan
    Commented Oct 10, 2014 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
    Commented Oct 10, 2014 at 18:14

4 Answers 4

12

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.

0
9

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.

2
  • Looks promissing. I'll give it a try. Thanks!
    – NVaughan
    Commented Mar 28, 2019 at 14:50
  • 2
    The bug-hunter is awesome! Thanks for pointing this out.
    – mforbes
    Commented Jan 18, 2020 at 21:35
1

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

1
  • You can and should accept your own answer. It's a nice incentive for those like you who both find their own answer and come back and post it. Commented Apr 28, 2022 at 14:53
0

When you start your Emacs, a *Messages* buffer is automatically opened. Go to this buffer to see what happened.

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.