2

OS: Windows XP, Emacs: 24.5.1.

I installed bookmark+ package using Melpa. It was put into directory:

~/.emacs.d/elpa/bookmark+-20151107.847

When I put (require 'bookmark+) to the end of ~/.emacs, I get an error:

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

File error: Cannot open load file, no such file or directory, bookmark+

But after Emacs is fully loaded, if I evaluate form (require 'bookmark+) --- it loads the appropriate module.

So, it seems, that it doesn't search for the library in ~/.emacs.d/elpa/bookmark+-20151107.847 directory while .emacs is being loaded.

How to fix?

1

1 Answer 1

2

Add the following line to your init.el file before you require the package (require 'bookmark+).

(package-initialize)
5
  • 3
    This is not the way to deal with ELPA packages.
    – phils
    Commented May 3, 2016 at 9:20
  • Sorry for not reading the question so carefully. So package-initializewill be needed.
    – husky
    Commented May 3, 2016 at 12:28
  • 2
    Adding manually to load-path was indeed not right, but calling package-initialize is the right solution. Emacs-25 will even automatically add that call to your ~/.emacs (in some cases) if you haven't done so yet.
    – Stefan
    Commented Jul 27, 2016 at 21:32
  • @YoungFrog: the autoloads will be setup by package-initialize, so calling package-initialize is the right thing to do regardless of whether you want to require the package or not.
    – Stefan
    Commented Jun 27, 2017 at 19:10
  • @Stefan I meant that since the autoloads exist, require is not needed. And if require is not used, then the problem disappears (because package-initialize is called by emacs). [But my comment was badly written (it took me a few seconds to understand it), so I've just deleted it.]
    – YoungFrog
    Commented Jun 27, 2017 at 20:17

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.