From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#63625: 29.0.90; package-install inserts package directory into load-path twice. Date: Mon, 22 May 2023 18:57:13 +0200 Message-ID: <87353ojod2.fsf@gmail.com> References: <4ACD9E26-B5A6-412E-8DFC-C09C05A4EACD@mac.com> <871qj8lp8u.fsf@gmail.com> <87bkicjvne.fsf@gmail.com> <877ct0js46.fsf@gmail.com> <83o7mcpdkk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23616"; mail-complaints-to="usenet@ciao.gmane.io" Cc: philipk@posteo.net, 63625@debbugs.gnu.org, monnier@iro.umontreal.ca, toddasmith@mac.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 22 18:58:44 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q18rs-0005uf-SB for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 May 2023 18:58:44 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q18rH-0000o1-Gl; Mon, 22 May 2023 12:58:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q18rD-0000nb-Pp for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 12:58:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q18rD-0003ax-HZ for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 12:58:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q18rD-0001cZ-5L for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 12:58:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 May 2023 16:58:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63625 X-GNU-PR-Package: emacs Original-Received: via spool by 63625-submit@debbugs.gnu.org id=B63625.16847746466159 (code B ref 63625); Mon, 22 May 2023 16:58:03 +0000 Original-Received: (at 63625) by debbugs.gnu.org; 22 May 2023 16:57:26 +0000 Original-Received: from localhost ([127.0.0.1]:36123 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q18qb-0001bG-Da for submit@debbugs.gnu.org; Mon, 22 May 2023 12:57:25 -0400 Original-Received: from mail-wr1-f43.google.com ([209.85.221.43]:51227) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q18qY-0001an-C8 for 63625@debbugs.gnu.org; Mon, 22 May 2023 12:57:23 -0400 Original-Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3095b1b6e02so2091807f8f.2 for <63625@debbugs.gnu.org>; Mon, 22 May 2023 09:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684774635; x=1687366635; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=xe3BtlLNEyTEO/kUgt1WIqmlgKXzGXpjWK5O2TgnG4E=; b=Ncg5h4VlGVcre7cHMtdnZp6MYl/bNielieD5u+S6+tbu4E5TS4WiVFW8vNo55ebbFF XH+55LjsGN6Ta7kazhWlddREc7hv75pbaS4Jo4LUjXaWvi0bDJPxDnnpc8my5YemWPU7 e0O2tiR6dGKLBauTRk+7KzOKbGhBxavrAJE5Ozqp3goSoLX1s3RSdkjU/J/WSSc6G3a7 sNftOoOJLzfwPjmr/iHTA8c+0KvOSg/a9bcw6Sid1S8JSo4+hyeqYobsxmuMSE22fbyG Sbg+3RLGomT0koS10aKcH/na34DvC6f3JOxQZE3G1AQQdbPYhxa3qRr/wbv6OFy7N6+B Clwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684774635; x=1687366635; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xe3BtlLNEyTEO/kUgt1WIqmlgKXzGXpjWK5O2TgnG4E=; b=VdfSYeltJvVRtuYoNBpAQCOiaGagsgbGrRUMM7JU5YKedDQarzr3PXbUUXCsLZJ6wg teAJg2wtbrDekhQctLwyYVmsAL2YYo5E9cu25LXctckvuoJVamTEbfYIPd1mLF3hX0W4 HPC6KO2IbZ5DOOCWykMA5XipdOblVcCzgZnIxjaVCFtma1An5yVNoMwSos2I8/Qu+lRC UYy+nPeVKUOP/xnrSkTNJw5mpeEicrmsQvgWKO52EKIRY2UaVwfLLguXPOxAN437yAVI lVlITpQUMqOn00IhREXsCTJEdOfmJLyJAuCwsNoSsUEz+Xx+HYFoewQIhgk+lVfzIpo4 SY4A== X-Gm-Message-State: AC+VfDzN4g4XoXx6U6Ft1HUX6PjNysfIq2xTa/89GbHxIB3jFgtUv8ia EgVoD5G/IroLhd6XdyhNWW4NhToFO7Y= X-Google-Smtp-Source: ACHHUZ4LyaE1qz38wFrVQRY/mC22PNuPes5gXoJ46T+DZCrZ4x31lSLX/mNszsCWBiYF3c2Iba7lRA== X-Received: by 2002:a5d:56d2:0:b0:2fe:c0ea:18b4 with SMTP id m18-20020a5d56d2000000b002fec0ea18b4mr8468205wrw.24.1684774635317; Mon, 22 May 2023 09:57:15 -0700 (PDT) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id b10-20020adfde0a000000b003021288a56dsm8307460wrm.115.2023.05.22.09.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 09:57:14 -0700 (PDT) In-Reply-To: <83o7mcpdkk.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 22 May 2023 18:53:47 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:262172 Archived-At: --=-=-= Content-Type: text/plain >>>>> On Mon, 22 May 2023 18:53:47 +0300, Eli Zaretskii said: >> Cc: Philip Kaludercic , 63625@debbugs.gnu.org, >> todd smith >> From: Robert Pluim >> 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 -- --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Avoid-duplicate-load-path-entry-when-generating-pack.patch >From 713da42a9c4569093368dcc41f606fb460fcd0e1 Mon Sep 17 00:00:00 2001 From: Robert Pluim 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-Avoid-duplicates-when-adding-package-dirs-to-load-pa.patch >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 --=-=-=--