Emacs 24 ELPA Update

In my ELPA With Emacs 24 post, I documented some of the problems I was having getting ELPA to work with Emacs 24 and showed some Elisp to work around the problem. Fortunately, my readers are a lot smarter than I am and suggested better ways of getting things to work.

The answer turns out to be pretty simple. I replaced all my special code for setting paths and requiring package with:

(package-initialize)
(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/"))

and left everything else the same. So far that seems to be working perfectly. The documentation isn't really clear on this and, in fact, hints that putting

(package-initialize)

in your .emacs or init.el file can cause problems with other packages. I haven't seen that and neither have any of my commenters so unless I run into problems later, my recommendation is to simply add the package-initialize near the top of your .emacs or init.el.

None of this means, of course, that you won't have to configure some of the packages you load with ELPA but at least Emacs won't throw an error during startup because of missing packages. Thanks to Seth, Philipp, and Foo for their helpful comments.

This entry was posted in General and tagged . Bookmark the permalink.

One Response to Emacs 24 ELPA Update

  1. Vedat Hallac says:

    I did have some problems around (package-initialize) in my init script, but it probably has something to do with the way I am doing things. The issue I had was with the package rinari. It has a configurable variable that affects what global functions are hooked, and I initialize package.el before I configure other packages. I ended up using (package-initialize t) early on, manually enabling packages I need for my configuration, and when all is done, calling (package-initialize) again to activate the rest of the installed packages.

    I am not sure this is the right way to do things, but I didn't want to read the package.el code to figure it out. Jiggling things around until nothing is obviously broken looks better for now. :)

    If anyone is interested, my package.el initialization file is at github.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>