Subject: bug#79411: 31.0.50; describe-package does not show :readme after package installation, but sth else

From: Philip Kaludercic <[email-masked]>
Date: Fri, 12 Sep 2025 09:23:41 +0000

Stephen Leake <[email-masked]> writes:

> Philip Kaludercic <[email-masked]> writes:
>
>>> Well, and Emacs did exactly that already until commit
>>> d4fb2690702fbd348977fc94a9f7a99c00cc3010 removed it.  Does anybody have
>>> an idea as to why that was removed?  (CCing Stephen, the author of that
>>> commit.)  The commit message does not quote a bug number, and the only
>>> bug I have found that might be related to this issue is bug#39609, which
>>> seems to be a duplicate of this one.
>>
>> On a quick glance, I cannot see the reason either.  But it seems like
>> the reasonable approach, and I don't see a reason why we shouldn't be
>> able to revert that part of the commit.
>
> I don't really remember, but I think the problem was there were old
> readme's hanging around, and the local file was prefered over network
> access, so when you asked for the readme for a package, you got the
> wrong one.
>
> If you can _guarrantee_ that the file is deleted when it's old, that
> would be ok. But that's pretty hard to do.

In my previous message I suggested something like:

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index ba9999c20e6..b9e2eb96389 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2162,7 +2162,15 @@ package-install-from-archive
                ;; Update the new (activated) pkg-desc as well.
                (when-let* ((pkg-descs (cdr (assq (package-desc-name pkg-desc)
                                                  package-alist))))
-                 (setf (package-desc-signed (car pkg-descs)) t))))))))))
+                 (setf (package-desc-signed (car pkg-descs)) t)))))))
+      ;; fetch a backup of the readme file from the server
+      (let ((readme (expand-file-name "README-elpa" (package-desc-dir pkg-desc))))
+        (unless (file-readable-p readme)
+          (package--with-response-buffer (package-archive-base pkg-desc)
+            :file (format "%s-readme.txt" (package-desc-name pkg-desc))
+            :noerror t
+            (write-region nil nil readme)))))))
+
 
 ;;;###autoload
 (defun package-installed-p (package &optional min-version)

As we store the README file inside the package directory, it should also
be deleted when we delete the package -- unless I am missing something?