0

This are the first 4 lines of my init.el

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(setq package-enable-at-startup nil)

After loading emacs all the entries (elpa/package.version) added by package-initialize to the load-path are in it twice, once without a trailing slash and once with it.

Does anyone know why it does this? Won't it slow things down by searching the directories twice?

It made me think I was adding them to the load path twice, but I'm not.

  • Are you loading any packages that automatically set the load-paths in your init file. Perhaps this is happening in another part of the init file. package-initialize only loads with a trailing /, so something else is adding those paths. Even if speed is not an issue, some search tools redundantly show multiple hits for the same hit, once for each path. – Emacs User Jun 12 '15 at 17:32
  • I don't think so. Even if I comment out everything but those 4 lines I get the duplicates. – spelufo Jun 12 '15 at 18:36
2

Use these lines to avoid duplicate paths in load-path after package-initialize:

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(package-initialize)
(setq package-enable-at-startup nil)

Not providing the t value to add-to-list as optional APPEND argument avoids duplicate load-paths. To add-to-list to the end of the list without using the t value, then use this variation:

(require 'package)
(reverse (cons '("melpa" . "http://melpa.org/packages/") (reverse 'package-archives)))
(package-initialize)
(setq package-enable-at-startup nil)
  • 1
    That puts melpa first on the package-archives list. I don't know why that fixes the duplicates, but thank you very much. The melpa guys should change the instructions on their getting started page – spelufo Jun 13 '15 at 13:10

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.