I installed the flx-ido package from MELPA, and added the following two lines of code to my .emacs file.

(require 'flx-ido) (flx-ido-mode 1)

Emacs startup fails with the following error:

File error: Cannot open load file, no such file or directory, flx-ido

Yet, after I see the error, I can type M-x flx-ido-mode and the flx-ido-mode operations start to work fine. So the flx-ido files must have been loaded.

I don't understand how this behavior is possible. Does anyone have some ideas that I might try to solve the problem?


Emacs initializes the package system after loading .emacs, not before. (See Startup Summary and Packaging Basisc.) I think the reason is to allow you to configure (or even disable) the package loading process from .emacs.

You can add flx-ido-mode to after-init-hook. Or you can follow the officious advice which is to call package-initialize from your init file. After that point, you can load packages. flx-ido-mode should be autoloaded, there's no need to load the package explicitly.

(flx-ido-mode 1)
  • Gilles, thank you so much for explaining the order of package-initialize. Sure enough, it was located AFTER flx-ido-mode in the load sequence. I have moved the package-initialize (and melpa paths, etc) earlier in my load sequence, and now everything works fine. Excellent answer! – Kevin May 12 '16 at 14:34

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.