From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#65475: 29.1; package-selected-packages variable is not updated when the last package is deleted Date: Sun, 10 Sep 2023 11:57:38 +0000 Message-ID: <87fs3mxmtp.fsf@posteo.net> References: <61352d45-21a6-466b-be7b-7755a6260356@gmail.com> <83a5uemfxy.fsf@gnu.org> <87o7iutg4i.fsf@posteo.net> <4604c3e3-8a6a-41b0-bf4d-9c087f151961@gmail.com> <87h6o8eec3.fsf@posteo.net> 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="2603"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andrey Samsonov , Eli Zaretskii , Eshel Yaron , Stefan Monnier , 65475@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 10 13:58:15 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 1qfJ4w-0000Ot-Kz for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Sep 2023 13:58:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qfJ4m-0007df-5M; Sun, 10 Sep 2023 07:58:04 -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 1qfJ4h-0007dK-0H for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2023 07:57:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qfJ4g-0006CP-Or for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2023 07:57:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qfJ4k-0004dP-4l for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2023 07:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Sep 2023 11:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65475 X-GNU-PR-Package: emacs Original-Received: via spool by 65475-submit@debbugs.gnu.org id=B65475.169434707117799 (code B ref 65475); Sun, 10 Sep 2023 11:58:02 +0000 Original-Received: (at 65475) by debbugs.gnu.org; 10 Sep 2023 11:57:51 +0000 Original-Received: from localhost ([127.0.0.1]:49175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfJ4Z-0004d0-5a for submit@debbugs.gnu.org; Sun, 10 Sep 2023 07:57:51 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:58515) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfJ4W-0004cn-JL for 65475@debbugs.gnu.org; Sun, 10 Sep 2023 07:57:49 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 6DB9F240103 for <65475@debbugs.gnu.org>; Sun, 10 Sep 2023 13:57:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1694347059; bh=saTCl6ByC+Aia5KCRaUJ2xJxsy3aXpX7os21az4ucnM=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=EoHiwAtz6hRK21DlDw194ckRhzEIa4exIbJNOs4uPy0J3ZqP9s/7jg09VV9p2G1C9 tYF9pn2vEo3oqYZ/y8E76EEJ+QExWMskQbcItWlnPjUeOL2N2ARdddfG5/+gWRFA3G hiDYX70P04Jo+zNTSQdWCR7e9YdOqxG08JwEa1pIIZOi3AY2UApuj2kXBtyOhUU+vb 2VVPt+5GWqL7klpScsujWsISBST1nYYQlsvBGy/MG9SpbTRjRR8lyZkMGsHBrgq5Xa y6uIVNBFPl+F2rUQ0GLl5ZB1CKZwdDLWZxA8X4FEHqDR7JTrYTvEDm4t7nOpcBw7i7 9w16ajK+3XC3A== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Rk7dG4XfYz6twH; Sun, 10 Sep 2023 13:57:38 +0200 (CEST) In-Reply-To: (Stefan Kangas's message of "Tue, 5 Sep 2023 15:03:23 -0700") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM 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:269952 Archived-At: --=-=-= Content-Type: text/plain Stefan Kangas writes: > reopen 65475 > thanks > > Eshel Yaron writes: > >>>> FWIW, I get the same non-empty `package-selected-packages` with Emacs >>>> master built from source. Indeed it looks like this issue isn't fully >>>> fixed yet. >>> >>> Even if 610105ee81bbf79f72d4efb46d0caddf8d654cf1 was applied? >> >> Of course. > > Thanks for testing. I'm reopening the bug. Following Eshel's diagnosis, it seems it should be possible to solve the bug by dynamically binding package-alist without the deleted package and then updating the top-level value if everything went right: --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 3a019905960..ed7d666ebf4 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2533,42 +2533,44 @@ package-delete ;; upgraded package. (package--newest-p pkg-desc)) (package--save-selected-packages (remove name package-selected-packages))) - (cond ((not (string-prefix-p (file-name-as-directory - (expand-file-name package-user-dir)) - (expand-file-name dir))) - ;; Don't delete "system" packages. - (error "Package `%s' is a system package, not deleting" - (package-desc-full-name pkg-desc))) - ((and (null force) - (setq pkg-used-elsewhere-by - (package--used-elsewhere-p pkg-desc))) - ;; Don't delete packages used as dependency elsewhere. - (error "Package `%s' is used by `%s' as dependency, not deleting" - (package-desc-full-name pkg-desc) - (package-desc-name pkg-used-elsewhere-by))) - (t - (add-hook 'post-command-hook #'package-menu--post-refresh) - (package--delete-directory dir) - ;; Remove NAME-VERSION.signed and NAME-readme.txt files. - ;; - ;; NAME-readme.txt files are no longer created, but they - ;; may be left around from an earlier install. - (dolist (suffix '(".signed" "readme.txt")) - (let* ((version (package-version-join (package-desc-version pkg-desc))) - (file (concat (if (string= suffix ".signed") - dir - (substring dir 0 (- (length version)))) - suffix))) - (when (file-exists-p file) - (delete-file file)))) - ;; Update package-alist. + (let ((package-alist ;see bug#65475 (let ((pkgs (assq name package-alist))) - (delete pkg-desc pkgs) - (unless (cdr pkgs) - (setq package-alist (delq pkgs package-alist)))) - (package--quickstart-maybe-refresh) - (message "Package `%s' deleted." - (package-desc-full-name pkg-desc)))))) + (if (null (remove pkg-desc (cdr pkgs))) + (remq pkgs package-alist) + package-alist)))) + (cond ((not (string-prefix-p (file-name-as-directory + (expand-file-name package-user-dir)) + (expand-file-name dir))) + ;; Don't delete "system" packages. + (error "Package `%s' is a system package, not deleting" + (package-desc-full-name pkg-desc))) + ((and (null force) + (setq pkg-used-elsewhere-by + (package--used-elsewhere-p pkg-desc))) + ;; Don't delete packages used as dependency elsewhere. + (error "Package `%s' is used by `%s' as dependency, not deleting" + (package-desc-full-name pkg-desc) + (package-desc-name pkg-used-elsewhere-by))) + (t + (add-hook 'post-command-hook #'package-menu--post-refresh) + (package--delete-directory dir) + ;; Remove NAME-VERSION.signed and NAME-readme.txt files. + ;; + ;; NAME-readme.txt files are no longer created, but they + ;; may be left around from an earlier install. + (dolist (suffix '(".signed" "readme.txt")) + (let* ((version (package-version-join (package-desc-version pkg-desc))) + (file (concat (if (string= suffix ".signed") + dir + (substring dir 0 (- (length version)))) + suffix))) + (when (file-exists-p file) + (delete-file file)))) + ;; Update package-alist. + (set-default-toplevel-value 'package-alist package-alist) + (package--quickstart-maybe-refresh) + (message "Package `%s' deleted." + (package-desc-full-name pkg-desc))))))) ;;;###autoload (defun package-reinstall (pkg) --=-=-= Content-Type: text/plain An alternative solution might just be to manually add a check at the end of package-delete to handle the proper removal of the last package. --=-=-=--