6

When I start up emacs, I see

Warning (initialization): Your `load-path' seems to contain
your `.emacs.d' directory: ~/.emacs.d/
This is likely to cause problems...
Consider using a subdirectory instead, e.g.: /home/faheem/.emacs.d/lisp

I think I started seeing this message relatively recently, but in any case, here are the relevant lines in my .emacs.

(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/contrib")

Here is what my emacs.d directory looks like:

faheem@orwell:~/.emacs.d$ ls
abbrev_defs     edit-server.el  session.10dbde7765000140938718700000055430258  session.10dbde7765000142073356500000315430010
auto-save-list  elpa            session.10dbde7765000141759448100000009970011  tramp

What am I doing wrong, if anything?

3
  • You are not doing anything wrong per se. This is a warning that this set up is not considered a good idea. At the moment having a set up like this will work fine.
    – verdammelt
    Commented Mar 7, 2015 at 15:35
  • Maybe you must recently upgraded emacs? I got this error when I upgraded from one version to another a while ago. 24.2 to 24.3 I think. Commented Mar 9, 2015 at 19:18
  • 1
    answered on SO.
    – sds
    Commented Jul 21, 2015 at 14:48

1 Answer 1

13

So when you read this warning message:

Warning (initialization): Your `load-path' seems to contain
your `.emacs.d' directory: ~/.emacs.d/
This is likely to cause problems...

and note that you have the following in your init file:

(add-to-list 'load-path "~/.emacs.d/")

hopefully you can recognise that this is exactly what the warning was referring to?

You need to follow the recommendation:

Consider using a subdirectory instead, e.g.: /home/faheem/.emacs.d/lisp

by changing that line in your init file to this:

(add-to-list 'load-path "~/.emacs.d/lisp")

and then create that sub-directory: mkdir ~/.emacs.d/lisp

and finally take any elisp libraries (excluding your init file) that you yourself placed directly in ~/.emacs.d/, and move them into the new lisp sub-directory (in this case it looks like edit-server.el is the only file you need to move).

(and of course in future, you would add custom elisp libraries into that lisp directory, instead of putting them in ~/.emacs.d).

10
  • I still don't understand why the earlier setup is wrong, and why I need to make this change. What about all the other directories in .emacs.d, e.g. elpa? Why don't they need to be moved? And will they still get loaded if I used .emacs.d/lisp instead? Commented Mar 7, 2015 at 11:48
  • 15
    There's a difference between ~/.emacs.d/ and its subdirectories. It's fine to add subdirectories of ~/.emacs.d to your load-path, but you should not add ~/.emacs.d/ to it. The reason is that Emacs libraries create data files in ~/.emacs.d/, which might accidentally shadow real libraries if you add ~/.emacs.d/ to your load-path.
    – user227
    Commented Mar 7, 2015 at 11:58
  • 1
    @lunaryorn thanks, that's a very helpful comment. Consider expanding it into a full answer. In particular, do you have a reference for "Emacs libraries create data files in ~/.emacs.d/, which might accidentally shadow real libraries"? An example woould be even better. Shadowing means loading your personal file of the same name because in the path before the real thing, right? I don't see why this would happen in this case. Commented Mar 8, 2015 at 5:12
  • 3
    calc.el is an example. That is both the name of an Emacs library, and also the name of a configuration file which it writes to your ~/.emacs.d/ directory. If that directory is in your load-path ahead of the standard library paths, then once calc has written its config file, you would be unable to load the calc library.
    – phils
    Commented Mar 8, 2015 at 5:22
  • 1
    But in short, your load path shouldn't include directories to which Emacs (or other applications for that matter) are liable to write arbitrary files, and ~/.emacs.d is such a directory.
    – phils
    Commented Mar 8, 2015 at 5:28

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.