Subject: bug#48137: 27.2; `package-install-file' fails when loading a package file with DOS line endings

From: Ioannis Kappas <[email-masked]>
Date: Sat, 1 May 2021 12:38:41 +0100

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.