mbarkhau / markdown-katex

Adds KaTeX support for Python Markdown
MIT License
16 stars 10 forks source link

No such file or directory: /tmp/mdkatex/adcebc8e8ae41063cc456af7bc8c63e5b2023b67b78beea322358d8b8b4409d5.tex #16

Open dwLG00 opened 1 year ago

dwLG00 commented 1 year ago

Whenever I run md.convert(), I get hit with some variation of the error No such file or directory: /tmp/mdkatex/adcebc8e8ae41063cc456af7bc8c63e5b2023b67b78beea322358d8b8b4409d5.tex (line 234 in _write_tex2html of wrapper.py). Looking in the code, it looks like the problem is caused by trying to delete a temporary tex file that was created but doesn't exist anymore for whatever reason. I'm confused because the file is explicitly created earlier on in _write_tex2html, and if there's any issues with the file creation it should just raise an error then.

The markdown-katex version: markdown-katex version: v202112.1034 (using binary: /usr/bin/npx --no-install katex) 0.16.8

mbarkhau commented 1 year ago

Thanks for the report. I vaguely remember dealing with this as a Heisenbug. If you can further debug this, I'd greatly appreciate it.

dwLG00 commented 1 year ago

Update: You were right about it being a heisenbug, it completely disappeared and everything is working properly. I think I'm going to leave the issue open just so people know it's a known issue

tovrstra commented 8 months ago

I'm running into this issue and can occasionally reproduce it, but only when generating many documents in parallel. Could this be a concurrency issue?

tovrstra commented 8 months ago

The following line is potentially causing this problem:

https://github.com/mbarkhau/markdown-katex/blob/4245dc101fe6c9e830f83fc8d12b1397c1dff29d/src/markdown_katex/wrapper.py#L32

When multiple processes are running this plugin, they operate in the same working directory, where one process is cleaning things up while another one is still using it. To avoid this, each wrapper instance can use mkdtemp instead.

I may give this a try to see if it helps.