bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#48137: 27.2; `package-install-file' fails when loading a package fil


From: Stefan Monnier
Subject: bug#48137: 27.2; `package-install-file' fails when loading a package file with DOS line endings
Date: Tue, 04 May 2021 11:57:53 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> > I think it's wrong for package.el to try to decode these files.  It
>> > should deliver the files to the disk exactly as they are received
>> > through the wire.  And the only safe way of doing that is to treat
>> > these files as raw bytes.
>> I'm not sure what you're referring to here.
> To the suggestion to decode *.el files by package.el as part of the
> installation.

Even for `package-install-file`?
[ which is a completely different code path than `package-install`.
  It's a kind of "side feature" to install packages
  using `package.el` without using an ELPArchive.  ]

>> In the OP's case, i.e. `package-install-file` (which is a seldom used
>> functionality, not part of the "normal" `package-install`) the file doesn't 
>> go
>> through the wire: it's already "local" and we currently implement this
>> code on top of `package-install-from-buffer`, so it has to work
>> correctly with an already-decoded buffer.
> If this works with buffer text, then how are DOS EOLs come into play
> here?  There are no CRLF pairs in decoded buffer text.

`package-install-file` takes a file, not a buffer, as input.
But internally it works by calling `package-install-from-buffer`.

Taking a step back, I think I'm just failing to understand why you
insist on not decoding the `.el` file.

What `package-install-file` will do is extract `<foo>-pkg.el` from it,
save a copy of the file somehow to `~/.emacs.d/elpa/<foo>/<foo>.el` and
then compile it.  After that, the file (neither the original file, nor
its copy in `~/.emacs.d/elpa/<foo>/<foo>.el`) will basically never be
used any more.  So the only "significant" uses of this file are
extraction of data for `<foo>-pkg.el` and byte-compilation, both of
which work on the decoded version of the file.

Furthermore, `insert-file-contents + write-region` should(!) preserve
the bytes in all normal cases.

I agree that in principle it would be better to copy the file by copying
its bytes than by `insert-file-contents + write-region`.

[ BTW, we have a bug in `package-install-from-buffer` currently for
  buffers which contain non-ASCII chars (because it saves the buffer's
  content via `package-unpack` => `package--write-file-no-coding`), so
  if we do go ahead with the change Ioannis proposes (which I think is
  acceptable) we definitely need to fix that bug in
  `package-install-from-buffer`.  ]


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]