From 983ed8b5d1f30e58be5d2e165cefefc8c70ae2f9 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 22 May 2023 18:49:26 +0200 Subject: [PATCH 2/2] Avoid duplicates when adding package dirs to load-path To: emacs-devel@gnu.org * 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. Do not merge to master, we're going to delete this code there. --- lisp/emacs-lisp/package.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 3d3da7909d7..4665ef0aa8e 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -904,7 +904,12 @@ package-activate-1 (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. -- 2.38.1.420.g319605f8f0