jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.81k stars 3.39k forks source link

Windows: infinite loop creating empty temp files when file deletion prohibited by ACL #10314

Open ZoomRmc opened 1 month ago

ZoomRmc commented 1 month ago

In an attempt to debug the temporary html file created producing the PDF file, the current working directory permissions were changed to prohibit file deletion. Running

pandoc --pdf-engine typst test.typ -o test.pdf

in this directory starts producing empty temporary files in an infinite loop and requires killing the process. Files are zero-length and of "tmp" extension, meaning it happens before Pandoc is able to write to it and save it.

Related:

  1. 2288 needs to be renamed and reopened as examining temporary files is not solved.

  2. The fact that pandoc creates an .html temporary which is in fact a typst template combined with the user-provided typst input is very confusing:
    • Why not use a proper file extension or just omit it? Fixed in 7330ad5
    • Shouldn't direct conversion omit templating altogether? Not sure on this one. duh
  3. Doesn't pandoc attempt to use %TEMP% on Windows? I was under impression it does.

Encountered with Pandoc 3.5 on Windows 10

jgm commented 1 month ago

On 3, see #777 for the reason for not using %TEMP%.

On 2, I'm baffled if an .html file is being produced! I would need to see why.

"Shouldn't direct conversion omit templating altogether? Not sure on this one." We need to create a standalone typst file to compile with typst. Doing this involves the template.

On 1, you're right that the method we mentioned for examining temp files doesn't work for e.g. typst, so perhaps we should reopen #2288.

ZoomRmc commented 1 month ago

On 2, I'm baffled if an .html file is being produced! I would need to see why.

To be clear, it's just the extension, the contents are correct typst. You're correct, wasn't thinking straight and forgot it goes through the intermediate representation anyway.

jgm commented 1 month ago

https://github.com/jgm/pandoc/blob/main/src/Text/Pandoc/PDF.hs#L482-L485

explains the .html. I guess in the past this function was just used for HTML, and I generalized it without changing the extension.