mystmd icon indicating copy to clipboard operation
mystmd copied to clipboard

PDF generation can be thwarted by a global .latexmrc file.

Open mforbes opened this issue 9 months ago • 3 comments
trafficstars

Description

If the user has a .latexmkrc file somewhere in a parent directory, then this will be included, potentially breaking the LaTeX build.

For example, when trying to build the quickstart guide, I ended up with an error:

$ myst build --pdf
...
Error: ENOENT: no such file or directory, open '.../mystmd-quickstart/_build/temp/mystSIQlNp/paper.log'

The issue is that my global .latexmkrc file was found with contains $out_dir = "/tmp/...";. This puts all latex compilation products in /tmp/..., and hence myst cannot find the final .pdf file. (In this case, I think something else was wrong with the build too which I will track down later, because I include a command to copy the final pdf back up...).

$ myst --version
v1.3.23

Proposed solution

I will have to explore how to do this, but for automated builds, latexmk should probably be told to ignore global configurations. This can be done with latexmk>=v. 4.27a by passing the -norc flag.

mforbes avatar Feb 11 '25 04:02 mforbes

It looks like the latexmk command line is fairly hard-coded:

https://github.com/jupyter-book/mystmd/blob/9b9fa00681be48f7afe4656c7e79b2810472d6ee/packages/jtex/src/tex/export.ts#L12

There should probably be a configuration variable allowing for customizations like included -norc (although, this should probably be the default). I am not sure if there is a suitable use-case where global latexmkrc customizations would be important for mystmd generation, but I expect there are cases, so there should be some option for doing this.

mforbes avatar Feb 11 '25 05:02 mforbes

If you add that -norc flag in the dev version (or just the compiled javascript which you can find under which myst and search for latexmk in any text editor, which might be easier for you to test?!). Does that fix the problem for you?

rowanc1 avatar Feb 11 '25 18:02 rowanc1

Yes. I installed the sources and ran from that, and adding -norc works for this particular issue. I expect this should be the default, but am trying to better understand the structure of the code so I can submit a PR because it should probably be configurable.

mforbes avatar Feb 11 '25 18:02 mforbes