unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48137: 27.2; `package-install-file' fails when loading a package file with DOS line endings
@ 2021-05-01 11:38 Ioannis Kappas
  2021-05-01 11:48 ` Ioannis Kappas
  0 siblings, 1 reply; 32+ messages in thread
From: Ioannis Kappas @ 2021-05-01 11:38 UTC (permalink / raw)
  To: 48137


[-- Attachment #1.1: Type: text/plain, Size: 1106 bytes --]

There is an issue with `package-install-file' that fails with the
following error when trying to install a file written with DOS line
endings:

error: Package lacks a "Version" or "Package-Version" header

(This is more apparent on MS-Windows which writes files with DOS line
endings by default)

To reproduce, create a minimal package file with Emacs on MS-Windows
and write it to disk as package-install-file-test-win.el:

;;; package-install-file-test-win.el --- test issue

;; Version: 0.1

(provide 'package-install-file-test-win)

;;; package-install-file-test-win.el ends here


Then M-x package-install-file RET package-install-file-test-win.el RET

and it should produce the error.

The above succeeds on GNU/Linux and installs the dummy package as
expected.

I have attached an ert test to do the same. The test fail on windows
and succeeds on Linux.

You can run it from command line as:

: emacs -Q --batch -l ert -l ./issue-package-install-file-test.el -f
ert-run-tests-batch

The cause appears to be that 'package can't handle package files
encoded with DOS line endings. Analysis to follow.

[-- Attachment #1.2: Type: text/html, Size: 1633 bytes --]

[-- Attachment #2: issue-package-install-file-test.el --]
[-- Type: application/octet-stream, Size: 1531 bytes --]

;;; -*- lexical-binding: t; -*-
(require 'ert)

(defconst test/package ";;; package-install-file-test-win.el --- test issue 

;; Version: 0.1

(defun package-install-file-test-win/5 () 5)

(provide 'package-install-file-test-win)

;;; package-install-file-test-win.el ends here
"
  "Minimal test package file")

(ert-deftest package-install-file ()
  "Test that package install file works on a minimal package file
written to disk by Emacs."
  (message ":system %s :version %s" system-configuration emacs-version)

  (let* ((temp-dir (make-temp-file "package-install-file-test-win" t))
         (package-path (expand-file-name
                        "package-install-file-test-win.el"
                        temp-dir)))
    ;; write file in the default encoding
    (with-temp-buffer
      (insert test/package)
      (write-region (point-min) (point-max) package-path))
    (message ":package-file-created-at %s" package-path)

    ;; report on file encoding
    (with-temp-buffer
      (insert-file-contents package-path)
      (let* ((contents (buffer-string)))
        (message ":package-file-coding-system %s" buffer-file-coding-system)))

    ;; install package
    (package-install-file package-path)
    (delete-directory temp-dir t)

    
    ;; call dummy function
    (require 'package-install-file-test-win)
    (should (equal 5 (package-install-file-test-win/5)))

    ;; remove package
    (package-delete (cadr (assq 'package-install-file-test-win package-alist)))))

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2021-07-20 13:54 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-01 11:38 bug#48137: 27.2; `package-install-file' fails when loading a package file with DOS line endings Ioannis Kappas
2021-05-01 11:48 ` Ioannis Kappas
2021-05-01 12:15   ` Eli Zaretskii
2021-05-01 13:51     ` Stefan Monnier
2021-05-03 17:47       ` Ioannis Kappas
2021-05-03 18:23         ` Stefan Monnier
2021-05-03 18:33           ` Eli Zaretskii
2021-05-03 18:49             ` Ioannis Kappas
2021-05-03 18:52               ` Eli Zaretskii
2021-05-03 20:12                 ` Stefan Monnier
2021-05-04 11:39                   ` Eli Zaretskii
2021-05-03 19:41             ` Stefan Monnier
2021-05-04 11:34               ` Eli Zaretskii
2021-05-04 15:57                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-04 16:14                   ` Eli Zaretskii
2021-05-04 16:27                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-04 16:51                       ` Eli Zaretskii
2021-05-05  7:03                         ` Ioannis Kappas
2021-05-05 12:01                           ` Eli Zaretskii
     [not found]                             ` <CAMRHuGAi9+q-MKRGPxLqxdP_7SSF4Nqj+JuSsZigviAQs_d7Rw@mail.gmail.com>
2021-05-06  6:55                               ` Ioannis Kappas
2021-05-06  8:12                                 ` Eli Zaretskii
2021-05-06 13:27                                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-06 15:26                                   ` Eli Zaretskii
2021-05-11  6:52                                     ` Ioannis Kappas
2021-05-11 12:55                                       ` Eli Zaretskii
2021-05-15 13:52                                         ` Ioannis Kappas
2021-05-16  9:09                                           ` Ioannis Kappas
2021-05-29  8:20                                             ` Eli Zaretskii
2021-05-29 13:59                                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-29 14:09                                                 ` Eli Zaretskii
2021-06-06  9:11                                                   ` Ioannis Kappas
2021-07-20 13:54                                                     ` Lars Ingebrigtsen

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).