all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Jimmy Wong <wyuenho@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, 63338@debbugs.gnu.org
Subject: bug#63338: 29.0.90; package-vc-install'ing the same package multiple times results in duplication in package-selected-packages
Date: Wed, 10 May 2023 06:56:07 +0000	[thread overview]
Message-ID: <87h6skfzeg.fsf@posteo.net> (raw)
In-Reply-To: <5727a6ad-b2c6-4c8f-ac85-b6478c57a749@Spark> (Jimmy Wong's message of "Tue, 9 May 2023 03:56:46 +0100")

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

Jimmy Wong <wyuenho@gmail.com> writes:

> I don’t think you should dedup the variable that could have been
> modified by something else such as package-install. This may make
> debugging harder should package.el itself introduce a bug that
> duplicates pacakages in the variable. How about just using good old
> add-to-list?

The issue is that we want to go through package--save-selected-packages,
that is given a new value to assign to `package-selected-packages'.
An otherwise, I my understanding is that add-to-list is not conventional
in executed code.

The alternative is to check for duplicates before invoking the function:


[-- Attachment #2: Type: text/plain, Size: 727 bytes --]

diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index e9794eac783..b967aaa3d4d 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -507,9 +507,10 @@ package-vc--unpack-1
         (package--reload-previously-loaded new-desc)))
 
     ;; Mark package as selected
-    (package--save-selected-packages
-     (cons (package-desc-name pkg-desc)
-           package-selected-packages))
+    (let ((name (package-desc-name pkg-desc)))
+      (unless (memq name package-selected-packages)
+        (package--save-selected-packages
+         (cons name package-selected-packages))))
     (package--quickstart-maybe-refresh)
 
     ;; Confirm that the installation was successful

[-- Attachment #3: Type: text/plain, Size: 913 bytes --]



> On 8 May 2023 at 1:03 PM +0100, Eli Zaretskii <eliz@gnu.org>, wrote:
>> > Cc: 63338@debbugs.gnu.org
>> > From: Philip Kaludercic <philipk@posteo.net>
>> > Date: Mon, 08 May 2023 10:36:55 +0000
>> >
>> > Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:
>> >
>> > > Reproduction:
>> > >
>> > > 0. (setq custom-file (const user-emacs-directory "custom.el"))
>> > > 1. M-x package-vc-install company
>> > > 2. M-x package-vc-install company RET y
>> > > 3. C-x C-f ~/.emacs/custom.el
>> > > 4. Observe that `company` has been listed twice under
>> > > `package-selected-packages`.
>> > >
>> > > Expectation:
>> > >
>> > > Installing the same package twice should not result in its duplication
>> > > in `package-selected-packages`.
>> >
>> > An easy fix would be just to ensure that package-selected-packages is
>> > always deduplicated before assigning the value:
>>
>> This is OK for the emacs-29 branch, thanks.

  reply	other threads:[~2023-05-10  6:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-06 23:27 bug#63338: 29.0.90; package-vc-install'ing the same package multiple times results in duplication in package-selected-packages Jimmy Yuen Ho Wong
2023-05-08 10:36 ` Philip Kaludercic
2023-05-08 12:04   ` Eli Zaretskii
2023-05-09  2:56     ` Jimmy Wong
2023-05-10  6:56       ` Philip Kaludercic [this message]
2023-05-13 17:18         ` Philip Kaludercic
2023-05-14 12:51           ` Jimmy Wong
2023-05-16 19:31             ` Philip Kaludercic

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6skfzeg.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=63338@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=wyuenho@gmail.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.