GNU bug report logs - #78636
30.1; package-install-file errors with some tar files

Previous Next

Package: emacs;

Reported by: Andy Rosen <ajr <at> corp.mlfs.org>

Date: Thu, 29 May 2025 20:02:02 UTC

Severity: normal

Found in version 30.1

Full log


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

From: Philip Kaludercic <philipk <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78636 <at> debbugs.gnu.org, Andy Rosen <ajr <at> corp.mlfs.org>
Subject: Re: bug#78636: 30.1; package-install-file errors with some tar files
Date: Mon, 09 Jun 2025 11:46:39 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Thu, 29 May 2025 15:56:31 +0000
>> From:  Andy Rosen via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> Running 'package-install-file' on a tar file might throw a 'Wrong type argument: arrayp, nil' error from
>> 'tar--check-descriptor’.  The problem comes from assumptions made by 'package--description-file' and
>> tar-mode about the filenames contained in the tar file.  I’ve written a detailed description of the error and
>> root cause here.

The issue make sense to me and we should fix it.

>> I propose adding a 'condition-case' to 'package-install-file' to return a friendly message.
>> 
>> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
>> index 82fcf439a11..01f659e6982 100644
>> --- a/lisp/emacs-lisp/package.el
>> +++ b/lisp/emacs-lisp/package.el
>> @@ -2439,8 +2439,10 @@ directory."
>>        (insert-file-contents-literally file)
>>        (set-visited-file-name file)
>>        (set-buffer-modified-p nil)
>> -      (when (string-match "\\.tar\\'" file) (tar-mode)))
>> -    (package-install-from-buffer)))
>> +      (when (string-match "\\.tar\\'" file) (tar-mode)
                                                ^
Please break the line here.  I initially missed the major-mode switch,
which confused me.

>> +            (condition-case nil
>> +                (package-install-from-buffer)
>> +       (error (message "%s is not a valid package file" (file-name-nondirectory file))))))))

I am not sure if this is just the formatting of the patch while
responding, but the indentation here is also misleading.

Also, can't we use `tar-header-block-tokenize' or some other function to
directly check if the file is a valid archive, instead of relying on
downstream signals being raised?

>>  
>>  ;;;###autoload
>>  (defun package-install-selected-packages (&optional noconfirm)
>> 
>> In GNU Emacs 30.1 (build 1, aarch64-apple-darwin21.6.0, NS
>>  appkit-2113.65 Version 12.7.6 (Build 21H1320)) of 2025-02-24 built on
>>  armbob.lan
>> Windowing system distributor 'Apple', version 10.3.2575
>> System Description:  macOS 15.5
>
> Philip, any comments?




This bug report was last modified 5 days ago.

Previous Next


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