Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pandoc error with word output and template #1062

Closed
cderv opened this issue Jan 20, 2021 · 9 comments
Closed

Pandoc error with word output and template #1062

cderv opened this issue Jan 20, 2021 · 9 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@cderv
Copy link
Collaborator

cderv commented Jan 20, 2021

This is also a problem for me (on a Mac)

This is interesting that you have that on Mac too!
Can you share the pandoc command line that should be shown when rendering the doc ?

Sorry, I hope I've posted in the right place...I'm not sure I have! I am trying to knit my bookdown to word, and it fails each time.

The error message:

pandoc: template.docx: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1

R version:

$platform
[1] "x86_64-apple-darwin17.0"

$arch
[1] "x86_64"

$os
[1] "darwin17.0"

$system
[1] "x86_64, darwin17.0"

$status
[1] ""

$major
[1] "4"

$minor
[1] "0.3"

$year
[1] "2020"

$month
[1] "10"

$day
[1] "10"

$`svn rev`
[1] "79318"

$language
[1] "R"

$version.string
[1] "R version 4.0.3 (2020-10-10)"

$nickname
[1] "Bunny-Wunnies Freak Out"

Mac is OS Catalina, 10.15.7

Thank you for your patience

Originally posted by @GabriellaS-K in rstudio/rmarkdown#701 (comment)

@cderv cderv changed the title > > This is also a problem for me (on a Mac) Pandoc error with word output and template Jan 20, 2021
@cderv
Copy link
Collaborator Author

cderv commented Jan 20, 2021

Hi @GabriellaS-K,

can you share more about the information in your YAML about the output format ?
Are you trying to use a template docx ?

Also can you share what is before the Pandoc error, the whole command line (usually it is in the rmarkdown pane in the IDE).

Thank you !

@cderv cderv added the question general questions - not an issue label Jan 20, 2021
@GabriellaS-K
Copy link

GabriellaS-K commented Jan 21, 2021

Hi,

Thank you so much! I'm trying to knit my bookdown files (which are kept on one drive) to a word document, using a word template (I followed Yihui Xie's wonderfully helpful Vimeo).

Below is the YAML for my index script:


#####################
## metadata ##
#####################
title: "xyzzy"
#####################
## Output ##
#####################

site: bookdown::bookdown_site
documentclass: book
output: 
 bookdown::gitbook: default
# bookdown::html_book:
 # toc: true
 # toc_depth: 3
 # toc_float: true
 # theme: "cerulean"
 # highlight: tango
 # code_folding: hide


 #bookdown::pdf_book:
 # toc: TRUE
 # number_sections: TRUE
#  template: null
#  includes:
#   in_header: _tex/preamble.tex
#   before_body: _tex/doc_preface.tex 
   
 word_document:
   reference_docx: "template.docx"
#   fig_caption: yes
#   md_extensions: +footnotes
#   toc: yes #un # these when want to do word


link-citations: yes
bibliography: GK_references.bib
csl: african-online-scientific-information-systems-harvard.csl
#biblio-style: african-online-scientific-information-systems-harvard.csl

#always_allow_html: yes #unhashtag for pdf
#classoption: oneside #unhashtag for pdf

In the 'build' pane, this is the full error message:


/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS _main.utf8.md --to docx --from markdown+autolink_bare_uris+tex_math_single_backslash --output _main.docx --lua-filter /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --highlight-style tango --reference-doc template.docx --citeproc 
output file: _main.knit.md
[WARNING] Citeproc: citation wickham2019a not found
pandoc: template.docx: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
In addition: There were 40 warnings (use warnings() to see them)
Please delete _main.Rmd after you finish debugging the error.
Execution halted

Exited with status 1.

Thank you again for your patience

@cderv
Copy link
Collaborator Author

cderv commented Jan 23, 2021

Sorry for the delay.
Where is located template.docx relative to your project ? It is currently not found by Pandoc when trying to build to work.
Is it in the root of your bookdown project ?

@GabriellaS-K
Copy link

Hi! My turn to apologise for the delay! The template.docx is in the same folder as the index and other chapters, not even in a subfolder!

@GabriellaS-K
Copy link

Funny enough, it works if the whole folder is on my desktop. But I work with a team, using one drive, and that's where it stops working. The contents of the folder is exactly the same, but if its on a local computer it works, if not-it doesn't. Its not a long term solution to keep downloading the folder and do it that way...

@cderv
Copy link
Collaborator Author

cderv commented Jan 29, 2021

Interesting. So this is a matter of network drive. We already have some issue in the past with this and Pandoc. The first issue you put this too could have been the right one.

Can you try also the same but without bookdown ? Using rmarkdown and word_document() with a template.
Should be the same issue right ?

Next test would be with pandoc only.

  • Write a simple test.md file
# This is a test file

With a paragraph
  • If you have Pandoc in the terminal, you can then use this commandline from the working directory
pandoc -t docx -o test.docx --reference-doc=template.docx test.md

Or using R:

rmarkdown::pandoc_convert(
  "test.md", "docx", output = "test.docx", 
  options = c("--reference-doc", "template.docx"))
)

Does it works ?

@cderv cderv added bug an unexpected problem or unintended behavior and removed question general questions - not an issue labels Jan 29, 2021
@GabriellaS-K
Copy link

Weirdly, this has fixed itself?? I'm now building the book from one drive, and it knits to word! Maybe a bug that sorted itself out?

Sorry for the slow responses, appreciate your time on this!

@cderv
Copy link
Collaborator Author

cderv commented Feb 11, 2021

That is great and it is really good news !

No worries on the time spent - if you encounter a new error, please reach out.

@cderv cderv closed this as completed Feb 11, 2021
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants