I've noticed a common theme in questions that are really about how to debug user init files. Examples:

And likely many others. I'm wondering if we should have a default FAQ or something to link to if the question seems to be actually focused on how to debug emacs init files as a whole, and not necessarily related to the specific problem they are asking about.

Topics that might be useful would be:

  • emacs --debug-init
  • debug-on-error
  • debug-on-quit
  • emacs -Q
  • minimal init files with package initialization to use with emacs -Q -l minimal-init.el
  • how to selectively load new packages into the minimal init until the problem re-appears.

I think it might be useful to tag questions like this with and possibly add the default answer on the tag help?

I realize that is already covering some of this, but seems more targeted at questions like Emacs won't load theme on startup, then the examples above?

3 Answers 3


You forgot one, which I find myself adding as a comment (and sometimes an answer) quite often:

  • Recursively bisect your init file until you locate the problematic code.

And I mention that you can do that by commenting out 1/2 of it, then 3/4, 7/8, 15/16, 31/32, 63/64, 127/128, 255/256, 511/512,... I mention that you can use comment-region to comment out a region, and use C-u with comment-region to uncomment a region. (People can disagree about whether comment-dwim is as good for uncommenting, but it is certainly an alternative.)

This simple tool is very effective (after determining, using emacs -Q, that the init file is problematic).

This is not obvious, even if we think it should be. I think we all tend naturally to think that we can smart-it-out, reasoning and guessing, to try to narrow things down more quickly than could be done by a systematic, blind, dumb, binary search. And sometimes we can. And sometimes we fool ourselves.

I know that I had to learn this lesson over and over. Like many others, I have a large init file, which loads many libraries etc. I've learned my lesson - but it did take a while: Let Mr. Binary Search do the hunting - there will be enough time for thinking once you find the problematic code. ;-)

  • 6
    What we really need is a package that automates the bisection. :-)
    – Malabarba
    Commented Nov 14, 2014 at 0:39
  • Maybe so. But why a package? Emacs itself should offer this out of the box, if it's helpful for Emacs users in general.
    – Drew
    Commented Oct 12, 2017 at 1:02
  • Well, for what it's worth, that package exists now. elpa.gnu.org/packages/bug-hunter.html But I agree that some debugging feature like that would be a great inclusion to core emacs.
    – Malabarba
    Commented Oct 17, 2017 at 23:17

This sort of thing is best handled by a “canonical question”: a question asking about a generic scenario (I have a problem due to something in my init file, how can I find out what's causing it?), with an answer (or several answers) covering the main cases and techniques. This question can be used as a duplicate target for closure and can also be used as a reference in comments and answers about the topic.

Using a question/answer pair is better than putting the information in a tag wiki because Q/A pairs are more visible (they turn up in searches, they're suggested when composing a title or a post body, etc.) and can be used as duplicate targets. The relevant tag wiki(s) (here, and ) should contain a link to the question.

Beware that getting a canonical question right can be tricky. There's a delicate balance between making the question and answers sufficiently widely applicable to be useful, and making them so general that the reader is drowned in information that isn't relevant to their situation.

  • Do you suggest we nominate an existing problem to be a canonical question, or that we make a new question that is intended to be canonical?
    – dgtized
    Commented Nov 13, 2014 at 2:22
  • 1
    @dgtized Canonicalizing an existing question often doesn't work well because it contains additional material that's specific to the original asker's situation. But sometimes it can be done. Do we already have a candidate? Commented Nov 13, 2014 at 2:47
  • Not really I just listed those three and they are all pretty targeted at a particular problem. I guess we just need a "How do I debug my Emacs configuration?".
    – dgtized
    Commented Nov 13, 2014 at 4:34
  • @dgtized In the current situation it's probably best to create a new one specifically for this purpose. Then the creator can make it community-wiki, and everyone can help.
    – Malabarba
    Commented Nov 13, 2014 at 12:30

Could we adopt some of the TeX.SE norms about minimal examples? Maybe it should be acceptable to comment "Please post a minimal init" when the question seems to need it.

Meta.TeX.SE: I've just been asked to write a minimal example, what is that?

  • I agree that posting such a comment can be helpful, but it should be done after (1) making sure that the problem is caused by code in OP's init-file (by trying to reproduce the problem with emacs -Q) and (2) narrowing down the problem to a few lines of code as described in @Drew's answer.
    – itsjeyd
    Commented Nov 12, 2014 at 9:09
  • @itsjeyd The point of this answer is precisely to make it clear that (2) is expected from the OP, prior to asking.
    – T. Verron
    Commented Nov 12, 2014 at 10:19
  • @T.Verron I got that (although the answer isn't super explicit about it). The point is that it's not necessarily obvious for everyone how to go about narrowing down the problem (we wouldn't be discussing what to do about questions requiring this type of feedback if it were), so it's important to explain to people how to do that before asking them to post contents of their init-file. That will make life easier for everyone ;)
    – itsjeyd
    Commented Nov 12, 2014 at 10:35
  • @itsjeyd Ah, yes, of course! The content of the link provided by purple_arrows above is precisely that: the answer to what is a MWE, and how to make one. This answer could maybe have been made more clearly linked to the question, but I read it as "yes we should have such a FAQ, and then we could ask users to always post a MWE when applicable".
    – T. Verron
    Commented Nov 12, 2014 at 10:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .