iandol / scrivomatic

A writing workflow using Scrivener's style system + Pandoc for output…
https://iandol.github.io/scrivomatic/
GNU General Public License v3.0
297 stars 30 forks source link

Conversion to PDF: cleanup via latexmk not working #31

Closed htvogler closed 4 years ago

htvogler commented 5 years ago

I would like to convert my Scrivener file to PDF via your pdf-refs template. Since I'm using the fixLaTeX postprocessor to replace missing glyphs, I also need to run latexmk, which produces the following error:

=== ------------------------------------------------------ ===
=== Scrivomatic V1.0.25 Report @ 2019-12-02 14:17:34 +0100 ===
=== ------------------------------------------------------ ===
 Running under Ruby 2.3.7
 Working directory: /Users/htv/Desktop/BIO_285_notes.md
===------ Input Options: ------===
#<struct Scrivomatic::OPT input="BIO_285_notes.md", output=nil, to=nil, yaml=nil, command="pandocomatic", envpath="/Users/htv/bin:/Users/htv/.rbenv/shims:/Library/TeX/texbin:/usr/local/bin:/Users/htv/.local/bin", build=false, cleanup=false, verbose=true, dry_run=false, open_log=true, data_dir=nil>
===------ Final ENV PATH: ------===
/Users/htv/bin:/Users/htv/.rbenv/shims:/Library/TeX/texbin:/usr/local/bin:/Users/htv/.local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
===------ TOOL PATHS: ------===
---pandoc: /usr/local/bin/pandoc | V: 2.7.2
---pandocomatic: /Users/htv/.rbenv/shims/pandocomatic | V: 
---ruby: /Users/htv/.rbenv/shims/ruby | V: ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
---rbenv: /usr/local/bin/rbenv
---python: /usr/local/bin/python
---xelatex: /Library/TeX/texbin/xelatex
---latexmk: /Library/TeX/texbin/latexmk

 … running pandocomatic, please wait …
===------ COMMAND OUTPUT: ------===
:: Running: /Users/htv/.rbenv/shims/pandocomatic --debug BIO_285_notes.md 
::: (4) + converting /Users/htv/Desktop/BIO_285_notes.md/BIO_285_notes.md 3 times:
::: (3)   - convert BIO_285_notes.md -> BIO_285_notes.docx
::: pandoc  --from=markdown \
:::     --to=docx \
:::     --standalone \
:::     --filter=/Users/htv/.local/share/pandoc/filters/removeHR \
:::     --filter=/Users/htv/.local/share/pandoc/filters/simplifyMetadata \
:::     --filter=/Users/htv/.local/share/pandoc/filters/prependAbstract \
:::     --filter=/Users/htv/.local/share/pandoc/filters/prependAll \
:::     --reference-doc=/Users/htv/.local/share/pandoc/templates/MyManuscriptReference.docx \
:::     --output=/Users/htv/Desktop/BIO_285_notes.md/BIO_285_notes.docx
::: (2)   - convert BIO_285_notes.md -> BIO_285_notes.pdf
::: pandoc  --to=latex \
:::     --pdf-engine=lualatex \
:::     --standalone \
:::     --filter=/usr/local/bin/pandoc-citeproc \
:::     --filter=/Users/htv/.local/share/pandoc/filters/assimilateMetadata \
:::     --bibliography=/Users/htv/switchdrive/COCB_Review/Literature/COCB_Review.json \
:::     --csl=/Users/htv/.local/share/pandoc/csl/current-opinion.csl \
:::     --from=markdown \
:::     --template=/Users/htv/.local/share/pandoc/templates/custom.latex \
:::     --base-header-level=2 \
:::     --output=/Users/htv/Desktop/BIO_285_notes.md/BIO_285_notes.pdf
::: [WARNING] Missing character: There is no ⇒ (U+21D2) in font Palatino:mode=node;+tlig;!
::: [WARNING] Missing character: There is no ⇒ (U+21D2) in font Palatino:mode=node;+tlig;!
::: Script does not exist: ''.
:: exit status: pid 6348 exit 243

!!!---scrivomatic::runCommand() RETURN non-zero value: /Users/htv/.rbenv/shims/pandocomatic --debug BIO_285_notes.md !!!

If I produce the PDF via the latex template it works fine. Do you have any idea what the problem is?

Thanks!

iandol commented 4 years ago

Personally I always output to TeX, and the use the -B option to actually build the PDF. You seem to be using the pandoc direct PDF output template?

hubertau commented 4 years ago

Hi Ian! Thank you so so much for an awesome tool, I've spent some time with it and I'm loving being able to export to multiple file types simultaneously.

I've also been trying to export to both Word and PDF simultaneously, and I get the same error code and 'Script does not exist' - the funny thing is the PDF still exports (seemingly) perfectly with no noticeable issues as of yet. Tried searching around for insights but I don't have any expertise in Ruby/Pandoc/Pandocomatic really. Thought I should post this here in case it helps you decode what's going on.

Separately, when you say you build with -B does that just mean scrivomatic -B my.tex?

=== ------------------------------------------------------ ===
=== Scrivomatic V1.0.27 Report @ 2020-04-12 17:29:03 +0800 ===
=== ------------------------------------------------------ ===
 Working directory: /Users/hubert/Desktop
 Initiating with Ruby 2.6.3
===------ Input Options: ------===
#<struct Scrivomatic::OPT input="Summative_Scrivener.md", output=nil, to=nil, yaml=nil, command="pandocomatic", envpath="/Users/hubert/bin:/Library/TeX/texbin:/usr/local/bin:/Users/hubert/anaconda3/bin:/Users/hubert/.local/bin", build=false, cleanup=false, verbose=true, dry_run=false, open_log=true, data_dir=nil>
===------ Final ENV PATH: ------===
/Users/hubert/bin:/Library/TeX/texbin:/usr/local/bin:/Users/hubert/anaconda3/bin:/Users/hubert/.local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/Scrivener.app/Contents/Resources/MultiMarkdown/bin
===------ TOOL PATHS: ------===
---pandoc: /usr/local/bin/pandoc | V: 2.9.2.1
---pandocomatic: /usr/local/bin/pandocomatic | V: 0.2.6
---ruby: /usr/bin/ruby | V: ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
---python: /Users/hubert/anaconda3/bin/python
---xelatex: /Library/TeX/texbin/xelatex
---latexmk: /Library/TeX/texbin/latexmk

 … running pandocomatic, please wait …
===------ COMMAND OUTPUT: ------===
:: Running: /usr/local/bin/pandocomatic --debug Summative_Scrivener.md 
::: (3) + converting /Users/hubert/Desktop/Summative_Scrivener.md 2 times:
::: (2)   - convert Summative_Scrivener.md -> Summative_Scrivener.docx
::: pandoc  --standalone \
:::     --verbose \
:::     --filter=/usr/local/bin/pandoc-citeproc \
:::     --filter=/Users/hubert/.local/share/pandoc/filters/prependAll \
:::     --filter=/Users/hubert/.local/share/pandoc/filters/simplifyMetadata \
:::     --lua-filter=/Users/hubert/.local/share/pandoc/filters/pagebreak.lua \
:::     --bibliography=/Users/hubert/.local/share/pandoc/Bibliography.json \
:::     --csl=/Users/hubert/.local/share/pandoc/csl/chicago-author-date.csl \
:::     --reference-links \
:::     --from=markdown \
:::     --to=docx \
:::     --reference-doc=/Users/hubert/.local/share/pandoc/templates/custom.docx \
:::     --output=/Users/hubert/Desktop/Summative_Scrivener.docx
::: [INFO] Running filter /usr/local/bin/pandoc-citeproc
::: [INFO] Completed filter /usr/local/bin/pandoc-citeproc in 79 ms
::: [INFO] Running filter /Users/hubert/.local/share/pandoc/filters/prependAll
::: [INFO] Completed filter /Users/hubert/.local/share/pandoc/filters/prependAll in 72 ms
::: [INFO] Running filter /Users/hubert/.local/share/pandoc/filters/simplifyMetadata
::: [INFO] Completed filter /Users/hubert/.local/share/pandoc/filters/simplifyMetadata in 56 ms
::: [INFO] Running filter /Users/hubert/.local/share/pandoc/filters/pagebreak.lua
::: [INFO] Completed filter /Users/hubert/.local/share/pandoc/filters/pagebreak.lua in 37 ms
::: [INFO] Not rendering RawInline (Format "tex") "\\cite{Amatulli}"
::: (1)   - convert Summative_Scrivener.md -> Summative_Scrivener.pdf
::: pandoc  --to=latex \
:::     --pdf-engine=xelatex \
:::     --standalone \
:::     --verbose \
:::     --filter=/usr/local/bin/pandoc-citeproc \
:::     --filter=/Users/hubert/.local/share/pandoc/filters/assimilateMetadata \
:::     --lua-filter=/Users/hubert/.local/share/pandoc/filters/pagebreak.lua \
:::     --bibliography=/Users/hubert/.local/share/pandoc/Bibliography.json \
:::     --csl=/Users/hubert/.local/share/pandoc/csl/chicago-author-date.csl \
:::     --reference-links \
:::     --from=markdown \
:::     --template=/Users/hubert/.local/share/pandoc/templates/custom.latex \
:::     --output=/Users/hubert/Desktop/Summative_Scrivener.pdf
::: [INFO] Running filter /usr/local/bin/pandoc-citeproc
::: [INFO] Completed filter /usr/local/bin/pandoc-citeproc in 69 ms
::: [INFO] Running filter /Users/hubert/.local/share/pandoc/filters/assimilateMetadata
::: [INFO] Completed filter /Users/hubert/.local/share/pandoc/filters/assimilateMetadata in 70 ms
::: [INFO] Running filter /Users/hubert/.local/share/pandoc/filters/pagebreak.lua
::: [INFO] Completed filter /Users/hubert/.local/share/pandoc/filters/pagebreak.lua in 24 ms
::: Script does not exist: ''.
:: exit status: pid 60941 exit 243

!!!---scrivomatic::runCommand() RETURN non-zero value: /usr/local/bin/pandocomatic --debug Summative_Scrivener.md !!!
iandol commented 4 years ago

Hi @hubertau, I always output to latex rather than final PDF with Pandoc, so for example in my scrivener metadata (build to docx and latex):

pandocomatic_:
  use-template: [docx-refs, latex-refs]

Then in the post-processing command-line if I want a PDF to be built from the latex: Screen Shot 2020-04-13 at 19 17 44

The benefit of this is I get the source .tex file I can inspect if there are some rendering errors or glitches (like missing references in the bib file), and I get more debug info in scrivomatic.log as I can capture all the output of latexmk (the tool that is used for building PDFs from latex files).

Pandoc's direct-to-pdf doesn't allow scrivomatic to capture or log the latex>pdf process so it is more opaque (although logging is getting better in Pandoc last few releases).

If the PDF and DOCX both build OK I would just ignore the error. I will check with one of my templates and a direct-to-PDF build later to see if I can reproduce the error...

iandol commented 4 years ago

OK, I can reproduce the error message too, and it is due to the cleanup section of pandocomatic.yaml, it contains the 'latexmk -c' command which is supposed to cleanup but for some reason pandocomatic can't find it (even though it is available in the path sent to pandocomatic as you can see in the top part of the log). Just remove this entry from your pandocomatic.yaml file and the error will go away, e.g.:

#-----------------------------------------------------------------------------
  pdf-refs:
    extends: [latex-refs]
    pandoc:
      to: pdf
      pdf-engine: 'xelatex'
    cleanup: []
hubertau commented 4 years ago

Oh fantastic! Thank you so much - glad to know the error can be cleaned up, though I agree now the -B flag makes more sense :)

iandol commented 4 years ago

I changed my pandocomatic.yaml, suggest those who have forked from mine do the same, and I'll close this...

htvogler commented 4 years ago

Thanks a lot, Ian! The -B flag is all it needs, really.