Error Cropping PDF Image Generating latex-image

53 views
Skip to first unread message

Chris Diaz

unread,
Feb 4, 2022, 5:10:48 PM2/4/22
to PreTeXt support
I'm having trouble debugging an error I'm getting using GitHub Actions to generate HTML output with TikZ generated <latex-images>. I'm using the PreTeXt-CLI on an Ubuntu 20.04 virtual machine.

It seems that the cropped version of the PDF figure is not found. I've confirmed that the pdf2svg executable is installed properly. Here is the git repo we are using and here is the workflow file running the action. 

And here's the error log:
```
Now generating latex-images

PTX: converting latex-image pictures from /home/runner/work/linear-algebra/linear-algebra/ptx/index.ptx to svg graphics for placement in /home/runner/work/linear-algebra/linear-algebra/generated-assets/latex-image
PTX: extracting latex-image pictures from /home/runner/work/linear-algebra/linear-algebra/ptx/index.ptx
PTX: string parameters passed to extraction stylesheet: {'publisher': '/home/runner/work/linear-algebra/linear-algebra/publication/publication.ptx'}
PTX: discovering source file's directory name: /home/runner/work/linear-algebra/linear-algebra/ptx
PTX: verifying and expanding input directory: /home/runner/work/linear-algebra/linear-algebra/ptx/../generated-assets
PTX: input directory expanded to absolute path: /home/runner/work/linear-algebra/linear-algebra/generated-assets
PTX: verifying and expanding input directory: /home/runner/work/linear-algebra/linear-algebra/ptx/../assets
PTX: input directory expanded to absolute path: /home/runner/work/linear-algebra/linear-algebra/assets
PTX: XSL conversion of /home/runner/work/linear-algebra/linear-algebra/ptx/index.ptx by /home/runner/.local/lib/python3.8/site-packages/pretext/static/xsl/extract-latex-image.xsl
PTX: converting im_matrix_mult.tex to im_matrix_mult.pdf
PTX: cropping im_matrix_mult.pdf to cropped-im_matrix_mult.pdf
PTX:ERROR: There was a problem cropping im_matrix_mult.pdf and cropped-im_matrix_mult.pdf was not created
Traceback (most recent call last):
  File "/usr/lib/python3.8/shutil.py", line 791, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: 'cropped-im_matrix_mult.pdf' -> 'im_matrix_mult.pdf'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/.local/bin/pretext", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/.local/lib/python3.8/site-packages/pretext/cli.py", line 197, in build
    project.build(target_name,webwork,diagrams,diagrams_format,only_assets,clean)
  File "/home/runner/.local/lib/python3.8/site-packages/pretext/project.py", line 258, in build
    builder.diagrams(target.source(), target.publication(), target.generated_dir(), target.stringparams(), target.format(), diagrams_format)
  File "/home/runner/.local/lib/python3.8/site-packages/pretext/build.py", line 54, in diagrams
    core.latex_image_conversion(
  File "/home/runner/.local/lib/python3.8/site-packages/pretext/static/pretext/pretext.py", line 338, in latex_image_conversion
    shutil.move("cropped-"+latex_image_pdf, latex_image_pdf)
  File "/usr/lib/python3.8/shutil.py", line 811, in move
    copy_function(src, real_dst)
  File "/usr/lib/python3.8/shutil.py", line 435, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.8/shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'cropped-im_matrix_mult.pdf'
Error: Process completed with exit code 1.
```

Any ideas?

Alex Jordan

unread,
Feb 4, 2022, 5:30:38 PM2/4/22
to pretext...@googlegroups.com
It appears to be failing to convert
im_matrix_mult.tex
into
im_matrix_mult.pdf

In other words, it's not about the cropping utility or the pdf2svg utility.

Can you run with extra verbosity? ( I think -vv, but not sure when
using the CLI.) That should leave the temp folder in place where the
.tex file was made (instead of trashing that temp folder at the end).
And then the terminal output reports where that temp folder is. Go
grab the .tex file and see if running pdflatex on it explains why it
did not make a pdf.
> --
> You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-support/5cdd5f5a-8437-4144-96ce-202ea81d404an%40googlegroups.com.

Steven Clontz

unread,
Feb 5, 2022, 11:20:07 AM2/5/22
to PreTeXt support
First, while I've been thinking we needed to use Actions for CI/testing purposes, I don't know why it never occurred to me to use Actions to handle (presumably) GitHub Pages builds. This might ultimately be slicker than the current workflow we recommend.

Speaking of which, the way we currently recommend distributing your HTML build is to use `pretext publish` locally. Pretext publish will git add/commit any outstanding changes if any, then copy the latest local build to docs, git add/commit that copy separately, and push.

My guess is that your Actions VM doesn't have a LaTeX compiler, which is why the PDF isn't made.

To get full verbosity with the CLI, run

pretext -v DEBUG build

Chris Diaz

unread,
Feb 7, 2022, 11:47:05 AM2/7/22
to PreTeXt support
Thanks for the help! I didn't know about the -v option for the CLI. It does seem like the PDF images are not getting generated. I'm not sure why, though, because both pdflatex and xelatex programs are available. Now I'm wondering if maybe there's a problem with my project manifest?

Here's the latest log:

xelatex --version
45 pdflatex --version
46 pretext -v DEBUG build html -d
47 shell: /usr/bin/bash -e {0}
48XeTeX 3.141592653-2.6-0.999993 (TeX Live 2021)
49kpathsea version 6.3.3
50Copyright 2021 SIL International, Jonathan Kew and Khaled Hosny.
51There is NO warranty. Redistribution of this software is
52covered by the terms of both the XeTeX copyright and
53the Lesser GNU General Public License.
54For more information about these matters, see the file
55named COPYING and the XeTeX source.
56Primary author of XeTeX: Jonathan Kew.
57Compiled with ICU version 68.2; using 68.2
58Compiled with zlib version 1.2.11; using 1.2.11
59Compiled with FreeType2 version 2.10.4; using 2.10.4
60Compiled with Graphite2 version 1.3.14; using 1.3.14
61Compiled with HarfBuzz version 2.7.4; using 2.7.4
62Compiled with libpng version 1.6.37; using 1.6.37
63Compiled with pplib version v2.05 less toxic i hope
64Compiled with fontconfig version 2.11.0; using 2.13.1
65pdfTeX 3.141592653-2.6-1.40.23 (TeX Live 2021)
66kpathsea version 6.3.3
67Copyright 2021 Han The Thanh (pdfTeX) et al.
68There is NO warranty. Redistribution of this software is
69covered by the terms of both the pdfTeX copyright and
70the Lesser GNU General Public License.
71For more information about these matters, see the file
72named COPYING and the pdfTeX source.
73Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
74Compiled with libpng 1.6.37; using libpng 1.6.37
75Compiled with zlib 1.2.11; using zlib 1.2.11
76Compiled with xpdf version 4.03
77PreTeXt project found in `/home/runner/work/linear-algebra/linear-algebra`.
78debug: XML syntax appears well formed.
79debug: PreTeXt document did not pass schema validation; unexpected output may result. See .error_schema.log for hints. Continuing with build.
80Preparing to build into /home/runner/work/linear-algebra/linear-algebra/public.
81Now generating latex-images
84PTX: converting latex-image pictures from /home/runner/work/linear-algebra/linear-algebra/ptx/index.ptx to svg graphics for placement in /home/runner/work/linear-algebra/linear-algebra/generated-assets/latex-image
85PTX:DEBUG: temporary directory for latex-image conversion: /tmp/tmpfdmnzo49
86PTX: extracting latex-image pictures from /home/runner/work/linear-algebra/linear-algebra/ptx/index.ptx
87PTX: string parameters passed to extraction stylesheet: {'publisher': '/home/runner/work/linear-algebra/linear-algebra/publication/publication.ptx'}
88PTX: discovering source file's directory name: /home/runner/work/linear-algebra/linear-algebra/ptx
89PTX: verifying and expanding input directory: /home/runner/work/linear-algebra/linear-algebra/ptx/../generated-assets
90PTX: input directory expanded to absolute path: /home/runner/work/linear-algebra/linear-algebra/generated-assets
91PTX: verifying and expanding input directory: /home/runner/work/linear-algebra/linear-algebra/ptx/../assets
92PTX: input directory expanded to absolute path: /home/runner/work/linear-algebra/linear-algebra/assets
93PTX: XSL conversion of /home/runner/work/linear-algebra/linear-algebra/ptx/index.ptx by /home/runner/.local/lib/python3.8/site-packages/pretext/static/xsl/extract-latex-image.xsl
94PTX:DEBUG: XSL conversion via /home/runner/.local/lib/python3.8/site-packages/pretext/static/xsl/extract-latex-image.xsl of /home/runner/work/linear-algebra/linear-algebra/ptx/index.ptx to None and/or into directory /tmp/tmpfdmnzo49 with parameters {'publisher': '/home/runner/work/linear-algebra/linear-algebra/publication/publication.ptx'}
95PTX:DEBUG: locating "tex" in [executables] section of configuration file
96PTX:WARNING: 'tex' is deprecated as a key for a LaTeX executable (2022-01-31)'
97 and has been replaced by 'latex', 'pdflatex', or 'xelatex'.
98*** We will attempt to honor your existing LaTeX engine choice. ***
99*** Edit the configuration file ("pretext.cfg" or "project.ptx") accordingly ***
58PTX:DEBUG: tex executable: xelatex, options:
59PTX:DEBUG: tex executable: xelatex
60PTX: converting im_matrix_mult.tex to im_matrix_mult.pdf
61PTX:DEBUG: locating "pdfcrop" in [executables] section of configuration file
62PTX:DEBUG: pdfcrop executable: pdf-crop-margins, options:
63PTX: cropping im_matrix_mult.pdf to cropped-im_matrix_mult.pdf
64PTX:ERROR: There was a problem cropping im_matrix_mult.pdf and cropped-im_matrix_mult.pdf was not created
65Traceback (most recent call last):
66 File "/usr/lib/python3.8/shutil.py", line 791, in move
67 os.rename(src, real_dst)
68FileNotFoundError: [Errno 2] No such file or directory: 'cropped-im_matrix_mult.pdf' -> 'im_matrix_mult.pdf'
70During handling of the above exception, another exception occurred:
72Traceback (most recent call last):
73 File "/home/runner/.local/bin/pretext", line 8, in <module>
74 sys.exit(main())
75 File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
76 return self.main(*args, **kwargs)
77 File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
78 rv = self.invoke(ctx)
79 File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
80 return _process_result(sub_ctx.command.invoke(sub_ctx))
81 File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
82 return ctx.invoke(self.callback, **ctx.params)
83 File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
84 return callback(*args, **kwargs)
85 File "/home/runner/.local/lib/python3.8/site-packages/pretext/cli.py", line 197, in build
86 project.build(target_name,webwork,diagrams,diagrams_format,only_assets,clean)
87 File "/home/runner/.local/lib/python3.8/site-packages/pretext/project.py", line 281, in build
88 builder.diagrams(
89 File "/home/runner/.local/lib/python3.8/site-packages/pretext/build.py", line 61, in diagrams
90 core.latex_image_conversion(
91 File "/home/runner/.local/lib/python3.8/site-packages/pretext/static/pretext/pretext.py", line 378, in latex_image_conversion
92 shutil.move("cropped-"+latex_image_pdf, latex_image_pdf)
93 File "/usr/lib/python3.8/shutil.py", line 811, in move
94 copy_function(src, real_dst)
95 File "/usr/lib/python3.8/shutil.py", line 435, in copy2
96 copyfile(src, dst, follow_symlinks=follow_symlinks)
97 File "/usr/lib/python3.8/shutil.py", line 264, in copyfile
98 with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
99FileNotFoundError: [Errno 2] No such file or directory: 'cropped-im_matrix_mult.pdf'
100Error: Process completed with exit code 1.

Steven Clontz

unread,
Feb 7, 2022, 12:11:07 PM2/7/22
to pretext...@googlegroups.com
Thanks for the github link and terminal output!

Looks like you're updated to CLI 0.6 which uses an updated project manifest to support various LaTeX interpreters. https://github.com/PreTeXtBook/pretext-cli/blob/main/templates/project.ptx#L37 You'll want to update someday but that's almost certainly (?) not your problem.

My next guess was that maybe there was an error with that particular latex-image source, but I was able to combine https://github.com/nulib-oer/linear-algebra/blob/main/ptx/index.ptx#L209 and https://github.com/nulib-oer/linear-algebra/blob/main/ptx/s_matrix.ptx#L350 in a vanilla LaTeX document and it ran just fine (both pdfLaTeX and XeLaTeX, powered by Overleaf).

Quick question - have you tried to `pretext build -d` locally to see what happens? Since you shared the repo I can give it a try this afternoon.


You received this message because you are subscribed to a topic in the Google Groups "PreTeXt support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-support/xEk9cWoFBMU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-suppo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-support/8ad03094-f703-410b-94f5-7a785c9858abn%40googlegroups.com.

Chris Diaz

unread,
Feb 7, 2022, 12:33:08 PM2/7/22
to PreTeXt support
Thanks! And if you give this a try yourself, note that I'm working from the `pretext-cli` branch of the repo. The goals for this branch are to use the CLI for processing and to offload latex-image generation to the GitHub Actions VM. Our current workflow is to build the TikZ images locally. When I run `pretext build html -d` locally, everything works as expected.

Rob Beezer

unread,
Feb 7, 2022, 12:39:38 PM2/7/22
to pretext...@googlegroups.com
On 2/7/22 9:10 AM, Steven Clontz wrote:
> You'll want to update someday but that's almost certainly (?) not your problem.

The line in the log

PTX:DEBUG: tex executable: xelatex

plus the four or five lines preceding, suggest the deprecation of the "tex" key
is being handled gracefully.

Rob

Steven Clontz

unread,
Feb 10, 2022, 7:35:18 PM2/10/22
to PreTeXt support
Sorry for delay, I finally looked at this.

I don't see any issues with running a local build. I was able to pretext publish things successfully to GitHub Pages here https://stevenclontz.github.io/linear-algebra-nulib-oer/s_matrix.html#d_matrix_mult

Bugfixing the GitHub Actions workflow is out of scope of what I can help with in the immediate future. I will open a PR to nulib-oer/linear-algebra with some tweaks to their pretext-cli branch to consider that should get them working with the supported pretext build && pretext publish workflow.

Doing builds in the cloud using GitHub Actions is tempting, but I endorse frequent local builds to preview changes while authoring, so it'd seem that doing the final build locally would make the most sense still.

Chris Diaz

unread,
Feb 11, 2022, 12:02:40 PM2/11/22
to PreTeXt support
Steven,

This is incredibly generous of you! Thank you so much for assistance with this. You definitely helped me with more questions I had beyond my original post. 

Cheers,
Chris

Steven Clontz

unread,
Feb 11, 2022, 3:59:11 PM2/11/22
to PreTeXt support
Since you had a repo set up it's no trouble. Gave me a thought to add GitHub info to a future `pretext support` output too... https://groups.google.com/g/pretext-dev/c/Dis03tiAISE/m/X2ZvbKuFBQAJ
Reply all
Reply to author
Forward
0 new messages