unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Alex Branham <alex.branham@gmail.com>,
	28502@debbugs.gnu.org,
	Noam Postavsky <npostavs@users.sourceforge.net>
Subject: bug#28502: 25.3; list-packages ends with "error in process filter: End of file during parsing"
Date: Mon, 21 Oct 2019 00:05:57 +0200	[thread overview]
Message-ID: <CADwFkmno6mKBVZOxN4DDaXghDN8UR0BksdU3ZP3rBbv6OS5x=A@mail.gmail.com> (raw)
In-Reply-To: <8760cfsxsw.fsf@gmail.com>

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

Michael Heerdegen <michael_heerdegen@web.de> writes:

> FWIW, I see now that my error was a bit different; I can still reproduce
> it with the copy of the file I had removed (it is attached):
>
> Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
>   package--add-to-archive-contents(nil "melpa")
>   package-read-archive-contents("melpa")
>   package-read-all-archive-contents()
>   package-initialize()
>   byte-code("..." 10)
>   load("~/gnu-emacs/.gnu-emacs")
>   eval-buffer(#<buffer  *load*> nil "/home/micha/.emacs" nil t)  ; Reading at buffer position 261
>   load-with-code-conversion("/home/micha/.emacs" "/home/micha/.emacs" t t)
>   load("~/.emacs" t t)
>   #f(compiled-function () #<bytecode 0x2567f5>)()
>   command-line()
>   normal-top-level()

Thanks for the archive-contents file and backtrace.

The file you saw contained a package entry that was nil.  My guess is
that this was due to an intermittent error on MELPA, since it was
well-formed in all other respects.

I don't think it's necessary to signal an error in this case.  We should
just ignore nil entries.  On the other hand, it might indicate that
something is wrong with the package archive, so it's nice to warn about
it.

I've installed the attached patch on master which does that.

Best regards,
Stefan Kangas

[-- Attachment #2: 0001-Don-t-try-to-add-nil-packages-on-refresh.patch --]
[-- Type: application/octet-stream, Size: 3033 bytes --]

From 0e6f4628d8fff53505e4399e71da9f531a64fff7 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sun, 20 Oct 2019 23:49:18 +0200
Subject: [PATCH] Don't try to add nil packages on refresh

* lisp/emacs-lisp/package.el (package-read-archive-contents): Don't
try to add nil entries.  Warn instead.  (Bug#28502)
* test/lisp/emacs-lisp/package-tests.el
(package-test-update-archives/ignore-nil-entry): New test.
* test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents:
New file.
---
 lisp/emacs-lisp/package.el                             |  5 ++++-
 .../package-resources/with-nil-entry/archive-contents  |  8 ++++++++
 test/lisp/emacs-lisp/package-tests.el                  | 10 ++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 20462064af..645e831bcc 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1520,7 +1520,10 @@ package-read-archive-contents
          (contents (package--read-archive-file contents-file)))
     (when contents
       (dolist (package contents)
-        (package--add-to-archive-contents package archive)))))
+        (if package
+            (package--add-to-archive-contents package archive)
+          (lwarn '(package refresh) :warning
+                 "Ignoring `nil' package on `%s' package archive" archive))))))
 
 (defvar package--old-archive-priorities nil
   "Store currently used `package-archive-priorities'.
diff --git a/test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents b/test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents
new file mode 100644
index 0000000000..03e6aa7f7c
--- /dev/null
+++ b/test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents
@@ -0,0 +1,8 @@
+(1
+ (foo .
+      [(1 0)
+      nil "foo package" single])
+ nil
+ (bar .
+      [(1 0)
+      nil "bar package" single]))
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el
index 8670e6f3fa..828c456842 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -452,6 +452,16 @@ package-test-update-archives-async
              (search-forward-regexp "^ +simple-single" nil t))))
       (if (process-live-p process) (kill-process process)))))
 
+(ert-deftest package-test-update-archives/ignore-nil-entry ()
+  "Ignore any packages that are nil.  Test for Bug#28502."
+  (with-package-test ()
+    (let* ((with-nil-entry (expand-file-name "package-resources/with-nil-entry"
+                                             package-test-file-dir))
+           (package-archives `(("with-nil-entry" . ,with-nil-entry))))
+      (package-initialize)
+      (package-refresh-contents)
+      (should (equal (length package-archive-contents) 2)))))
+
 (ert-deftest package-test-describe-package ()
   "Test displaying help for a package."
 
-- 
2.23.0


  parent reply	other threads:[~2019-10-20 22:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 17:48 bug#28502: 25.3; list-packages ends with "error in process filter: End of file during parsing" Alex Branham
2017-09-27  0:45 ` Noam Postavsky
2017-09-27 13:43   ` Michael Heerdegen
2017-09-27 14:06     ` Alex Branham
2017-09-27 14:47       ` Michael Heerdegen
2017-09-27 14:50         ` Alex Branham
2017-09-29 14:34     ` Michael Heerdegen
2019-10-20 22:05 ` Stefan Kangas [this message]
2019-10-21 10:14   ` Michael Heerdegen
2019-10-21 11:50     ` Stefan Kangas
2019-10-21  1:27 ` Stefan Kangas
2019-11-29 13:00   ` Stefan Kangas

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='CADwFkmno6mKBVZOxN4DDaXghDN8UR0BksdU3ZP3rBbv6OS5x=A@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=28502@debbugs.gnu.org \
    --cc=alex.branham@gmail.com \
    --cc=michael_heerdegen@web.de \
    --cc=npostavs@users.sourceforge.net \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).