Ok, this is a noob question but I've digging into this enough that I think it's reasonable to ask :)
My question: In one's .emacs / init.el file, can one use require
to load packages that were installed via the emacs package manager? If so, how?
I've seen a lot of code that says (require 'package-name)
, where 'package-name is something like 'powerline
or 'rainbow-delimiters
. The docs say that require
basically tries to load
the file, making sure not to load it twice. load
works by looking in all the dirs in the load-path
variable. This makes sense.
package-initialize
goes through the list of installed packages and tries to run their auto-loads (and possibly defer further work) so that all the packages I've previously installed will work. This makes sense.
My confusion comes from my init.el: even though I've got packages installed (I can both see the packages in the filesystem and everything works great if I run (package-initialize)
) using require
doesn't work. Emacs complains that use-package isn't in load-path
and I can confirm that if I don't call (package-initialize)
that the load-path
doesn't ilst ~/.emacs.d/elpa (or anything under it).
My question: In one's .emacs / init.el file, can one use require
to load packages that were installed via the emacs package manager? If so, how?
Do I need to manually add the directory to load-path
? Should this normally work and I probably broke something with my personal init.el?
Any help would be appreciated - I'm clearly not getting something about how require
works (and many other things too, I'm sure :) )
EDIT: My version: GNU Emacs 26.1 (build 1, x86_64-w64-mingw32) of 2018-05-30
Also, I'm playing around with use-package
and am running into the same problem - if I add the directory containing use-package
to load path without running (package-initialize)
first then use-package
fails because it wants to use the package bind-key
. bind-key
is installed but not listed in load-path
so emacs barfs at that point.
emacs -Q
, runM-x package-initialize
, and checkload-path
again. I have a similar system. After executing above steps I have manyload-path
entries withelpa
in them. The option-Q
essentially avoids loading the initialization files of the system and the user.package-initialize
and yet still run myinit.el
. My understanding is thatuse-package
can then lazy-load packages as I need them, thus reducing 'boot' times and giving me a snazzy, nice syntax for loading packages.emacs -Q
starts upload-path
doesn't have any paths to myelpa
dir. After I run(package-initialize)
thenload-path
does have a bunch ofelpa
directories. Is that what you were looking for? (I don't understand what this tells you?)