2

From time to time my Emacs doesn't load my init file at startup and gives me the following error message:

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

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.
File error: Cannot open load file, no such file or directory, session

The Problem turns out to be this code in my customization file:

(custom-set-variables
 ....
 '(session-use-package t nil (session))

It is a variable from the session package which saves my history in Emacs. I have to delete this line and everything works again. Why is this added to my customization file and how can I avoid this annoying error? How could I investigate myself which event triggers this setting in my customization file?

Edit: The part of my init which loads the package looks like this:

(use-package session
:ensure t
:init
(add-hook 'after-init-hook 'session-initialize))
8
  • The problem seems to be that emacs tries to require the session package (as per the REQUEST argument to custom-set-variables), and fails (probably because it is not found in load-path). Have you checked whether your init file contains everything needed to correctly and reliably load the session package? Aug 24 '15 at 21:50
  • @Francesco It is in the same path as all my other installed packages(elpa). I use use-package for this. I have added the part which loads the package to the question. The problem is I can not reproduce the error yet. It just happens sometimes.
    – clemera
    Aug 24 '15 at 23:20
  • 2
    When do you load your customization file? If it's before the after-init-hook, then that might be the problem.
    – sykora
    Aug 25 '15 at 13:51
  • 1
    When do you run package-initialize? This is when load-path gets populated and should happen before you load your customization file. Aug 26 '15 at 9:14
  • 1
    Yep, it probably will. But IIUC, the problem is not with session-initialize but rather package-initialize. Of course, if you load your custom file at the very end, everything should work fine. Aug 26 '15 at 14:43
2

The problem seems to be that emacs tries to require the session package (as per the REQUEST argument to custom-set-variables), and fails (probably because it is not found in load-path).

You have to make sure that your load-path is correctly populated before you load your customization file. In particular, if session is installed as an ELPA package, it means that package-initialize must be called before the customization file is loaded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.