0

I've got "Cannot open load file" error at (require 'org-mime) while load-path variable seems to be all right:

load-path is a variable defined in `C source code'.
Its value is
("/home/alexey/.emacs.d/elpa/bbdb-20130526.1945" "/home/alexey/.emacs.d/elpa/org-mime-20120112" "/home/alexey/.emacs.d/elpa/smex-20130421.2153" "/usr/share/emacs/24.3/site-lisp" "/usr/share/emacs/site-lisp" "/usr/share/emacs/24.3/lisp
...

Curiously, the remedy looks like this (.emacs):

(add-to-list 'load-path "~/.emacs.d/elpa/org-mime-20120112")

It isn't merely ugly: it's dysfunctional, because the versioned path is subject to change. But why the error?

Bibhas Debnath
  • 14,559
  • 17
  • 68
  • 96
Alexey Orlov
  • 2,412
  • 3
  • 27
  • 46
  • 5
    if you are using elpa system, you need first do (require 'package) (package-initialize) else emacs won't even see the load path. (i think. ) – Xah Lee May 27 '13 at 09:56
  • 1
    It's probably a problem of ordering in your .emacs, which causes the `(require 'org-mime)` to be run before the `load-path` is properly set. – Stefan May 27 '13 at 14:38

1 Answers1

0

There is an interesting issue that happens when you load a file that requires another file -- the file that is required must be loaded in chronological order before the next file. For example, if B requires A then A must be placed higher up in chronological order so that when B loads, A is already loaded.

I've had really good luck with this type of setup. Most files end with el or elc, so I'm not sure why you want to load a file with a different or no extension, but it is certainly possible to do that if you want.

(let* ((root.d "~/") (sub-dir (concat root.d ".emacs.d/")))
    (load-file (concat sub-dir "init.el"))
    (setq load-path
(append `(,root.d ,sub-dir
    ,(concat sub-dir "elpa/yasnippet")
) load-path)))
lawlist
  • 13,099
  • 3
  • 49
  • 158
  • Something like [this](http://stackoverflow.com/questions/7322246/adding-subdirectories-to-load-path), or so I gather. I can't understand your remark about extensions: all the targets are *.el so far. – Alexey Orlov May 27 '13 at 08:49
  • lawlist: If B requires A (such that it calls `(require 'A)`) and A is not already loaded, then it will be loaded at that time (provided it is in the load path, etc...). The call to `require` ensures that the required library is loaded before it is needed. You don't need to do anything manually. (Or if that's not what you meant, you may wish to clarify...) – phils May 27 '13 at 10:15
  • Ah - - - thank you -- I've been adding a lot of `el` manually when trying out new things -- I'll trying setting up a temporary load path for my testing and see if that helps -- there was recently an example of a circular A needs B, and B needs A ,to create a product of C and the load path might have fixed it. Always a pleasure to learn new tricks . . . :) – lawlist May 27 '13 at 15:35
  • @Alexey Orlov -- thank you -- looking at the numeric digits, I just assumed it was a file instead of a directory -- I stand corrected. – lawlist May 27 '13 at 15:37