GNU bug report logs - #56877
29.0.50; Built-in packages are not always package-installed-p

Previous Next

Package: emacs;

Reported by: Matt Armstrong <matt <at> rfc20.org>

Date: Mon, 1 Aug 2022 20:16:02 UTC

Severity: normal

Tags: patch

Found in version 29.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #13 received at 56877 <at> debbugs.gnu.org (full text, mbox):

From: Matt Armstrong <matt <at> rfc20.org>
To: 56877 <at> debbugs.gnu.org
Subject: Re: bug#56877: 29.0.50; Built-in packages are not always
 package-installed-p
Date: Mon, 01 Aug 2022 14:26:57 -0700
[Message part 1 (text/plain, inline)]
Matt Armstrong <matt <at> rfc20.org> writes:

> Matt Armstrong <matt <at> rfc20.org> writes:
>
>> I have a fix prepared, which I will send once i have a bug number.
>
> Now attached:

Second try.  Replaced "Foo" with a real docstring!

[0001-Consider-built-in-packages-to-be-installed.patch (text/x-diff, inline)]
From f66a0e6bf84f10d2688b2892a08e2d090e5bd6c7 Mon Sep 17 00:00:00 2001
From: Matt Armstrong <matt <at> rfc20.org>
Date: Mon, 1 Aug 2022 11:18:37 -0700
Subject: [PATCH] Consider built-in packages to be installed

With this change (package-installed-p PACKAGE nil) evaluates to the
same thing before and after package initialization.

* lisp/emacs-lisp/package.el (package-installed-p): Check for built-in
packages before initialization. (bug#56877)
---
 lisp/emacs-lisp/package.el            |  5 ++++-
 test/lisp/emacs-lisp/package-tests.el | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index df70f908da..482de52f85 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2085,7 +2085,10 @@ package-installed-p
          package-activated-list)
     ;; We used the quickstart: make it possible to use package-installed-p
     ;; even before package is fully initialized.
-    (memq package package-activated-list))
+    (or
+     (memq package package-activated-list)
+     ;; Also check built-in packages.
+     (package-built-in-p package min-version)))
    (t
     (or
      (let ((pkg-descs (cdr (assq package (package--alist)))))
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el
index d7a55998c2..b903cd781b 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -638,6 +638,21 @@ package-test-update-archives/ignore-nil-entry
       (package-refresh-contents)
       (should (equal (length package-archive-contents) 2)))))
 
+(ert-deftest package-test-package-installed-p ()
+  "Test package-installed-p before and after package initialization."
+  (with-package-test ()
+    ;; Verify that `package-installed-p' evaluates true for a built-in
+    ;; package, in this case `project', before package initialization.
+    (should (not package--initialized))
+    (should (package-installed-p 'project nil))
+    (should (not (package-installed-p 'imaginary-package nil)))
+
+    ;; The results don't change after package initialization.
+    (package-initialize)
+    (should package--initialized)
+    (should (package-installed-p 'project nil))
+    (should (not (package-installed-p 'imaginary-package nil)))))
+
 (ert-deftest package-test-describe-package ()
   "Test displaying help for a package."
 
-- 
2.35.1


This bug report was last modified 2 years and 298 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.