From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: philipk@posteo.net, 63625@debbugs.gnu.org,
monnier@iro.umontreal.ca, toddasmith@mac.com
Subject: bug#63625: 29.0.90; package-install inserts package directory into load-path twice.
Date: Mon, 22 May 2023 18:57:13 +0200 [thread overview]
Message-ID: <87353ojod2.fsf@gmail.com> (raw)
In-Reply-To: <83o7mcpdkk.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 22 May 2023 18:53:47 +0300")
[-- Attachment #1: Type: text/plain, Size: 1981 bytes --]
>>>>> On Mon, 22 May 2023 18:53:47 +0300, Eli Zaretskii <eliz@gnu.org> said:
>> Cc: Philip Kaludercic <philipk@posteo.net>, 63625@debbugs.gnu.org,
>> todd smith <toddasmith@mac.com>
>> From: Robert Pluim <rpluim@gmail.com>
>> Date: Mon, 22 May 2023 17:36:09 +0200
>>
Stefan> (package--reload-previously-loaded pkg-desc))
Stefan> (with-demoted-errors "Error loading autoloads: %s"
Stefan> (load (package--autoloads-file-name pkg-desc) nil t))
Stefan> - (add-to-list 'load-path (directory-file-name pkg-dir)))
Stefan> + ;; FIXME: Since 2013 (commit 4fac34cee97a), the autoload files take
Stefan> + ;; care of changing the `load-path', so maybe it's time to
Stefan> + ;; remove this fallback code?
Stefan> + (unless (or (member (file-name-as-directory pkg-dir) load-path)
Stefan> + (member (directory-file-name pkg-dir) load-path))
Stefan> + (add-to-list 'load-path pkg-dir)))
>>
Stefan> Maybe we can have that patch in emacs-29 and remove the code altogether
Stefan> on `master`?
>>
>> That seems reasonable. Eli?
Eli> I'm a bit confused by "that patch" and stuff, and would prefer to see
Eli> the patch for emacs-29 and another for master, please.
3 patches, 2 for emacs-29 below.
The 3rd one for master is just
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 2892728ebd9..28bac0401ed 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -902,7 +902,6 @@ 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)))
;; Add info node.
(when (file-exists-p (expand-file-name "dir" pkg-dir))
;; FIXME: not the friendliest, but simple.
Robert
--
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-duplicate-load-path-entry-when-generating-pack.patch --]
[-- Type: text/x-diff, Size: 1583 bytes --]
From 713da42a9c4569093368dcc41f606fb460fcd0e1 Mon Sep 17 00:00:00 2001
From: Robert Pluim <rpluim@gmail.com>
Date: Mon, 22 May 2023 15:44:21 +0200
Subject: [PATCH 1/2] Avoid duplicate load-path entry when generating package
autoloads
To: emacs-devel@gnu.org
'file-name-directory' produces a path ending in '/', so that needs to be
run through 'directory-file-name' to avoid duplicate entries in
'load-path'. (Bug#63625)
* lisp/emacs-lisp/package.el (package-generate-autoloads): Call
'directory-file-name' on the directory of 'load-file-name'.
---
lisp/emacs-lisp/package.el | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index c684840ab7e..3d3da7909d7 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1110,8 +1110,12 @@ package-generate-autoloads
;; Add the directory that will contain the autoload file to
;; the load path. We don't hard-code `pkg-dir', to avoid
;; issues if the package directory is moved around.
- (or (and load-file-name (file-name-directory load-file-name))
- (car load-path)))))
+ ;; `loaddefs-generate' has code to do this for us, but it's
+ ;; not currently exposed. (Bug#63625)
+ (or (and load-file-name
+ (directory-file-name
+ (file-name-directory load-file-name)))
+ (car load-path)))))
(let ((buf (find-buffer-visiting output-file)))
(when buf (kill-buffer buf)))
auto-name))
--
2.38.1.420.g319605f8f0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Avoid-duplicates-when-adding-package-dirs-to-load-pa.patch --]
[-- Type: text/x-diff, Size: 1605 bytes --]
From 983ed8b5d1f30e58be5d2e165cefefc8c70ae2f9 Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
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
next prev parent reply other threads:[~2023-05-22 16:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-20 21:45 bug#63625: 29.0.90; package-install inserts package directory into load-path twice todd smith via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-22 8:55 ` Robert Pluim
2023-05-22 11:25 ` Eli Zaretskii
2023-05-22 12:46 ` Robert Pluim
2023-05-22 13:18 ` Philip Kaludercic
2023-05-22 13:54 ` Robert Pluim
2023-05-22 13:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-22 14:19 ` Robert Pluim
2023-05-22 15:04 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-22 15:36 ` Robert Pluim
2023-05-22 15:53 ` Eli Zaretskii
2023-05-22 16:57 ` Robert Pluim [this message]
2023-05-23 12:06 ` Eli Zaretskii
2023-05-23 13:20 ` Robert Pluim
2023-05-23 13:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-22 15:49 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87353ojod2.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=63625@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=philipk@posteo.net \
--cc=toddasmith@mac.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).