]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid duplicates when adding package dirs to load-path
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 22 May 2023 16:49:26 +0000 (18:49 +0200)
committerRobert Pluim <rpluim@gmail.com>
Tue, 23 May 2023 12:12:21 +0000 (14:12 +0200)
Do not merge to master, we're going to delete this code there.

* lisp/emacs-lisp/package.el (package-activate-1): Check if the path
we're about to add is already in 'load-path', since package autoload
files have been updating 'load-path' for a decade.

lisp/emacs-lisp/package.el

index 0d90e4a4059e6f2c191aa99d70e0224c8aa1dc04..340ca9400fa541d332d9307a3e879c103742c169 100644 (file)
@@ -904,7 +904,12 @@ correspond to previously loaded files."
           (package--reload-previously-loaded pkg-desc))
         (with-demoted-errors "Error loading autoloads: %s"
           (load (package--autoloads-file-name pkg-desc) nil t))
-        (add-to-list 'load-path (directory-file-name pkg-dir)))
+        ;; FIXME: Since 2013 (commit 4fac34cee97a), the autoload files take
+        ;; care of changing the `load-path', so maybe it's time to
+        ;; remove this fallback code?
+        (unless (or (member (file-name-as-directory pkg-dir) load-path)
+                    (member (directory-file-name pkg-dir) load-path))
+          (add-to-list 'load-path pkg-dir)))
       ;; Add info node.
       (when (file-exists-p (expand-file-name "dir" pkg-dir))
         ;; FIXME: not the friendliest, but simple.