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

File is not found by pandoc when Evaluate chunk in Directory set to Project #1983

Closed
cderv opened this issue Dec 17, 2020 · 3 comments
Closed
Labels
question general questions - not an issue

Comments

@cderv
Copy link
Collaborator

cderv commented Dec 17, 2020

@eyayaw I don't think this is the same issue. i.e an issue with network drive as the last and recent comments are showing.

Pandoc will throw this error: openBinaryFile: does not exist (No such file or directory) when a file needed for the rendering is not found - but sometimes it is an indicator of an issue in the source file.

In your case, Pandoc is warning that the bib file referenced in your Rmd document is not found. You should check the bibliography field and the path of the file. Can you confirm that everything is ok on this side ?

Also about knitr:::knit2pdf, I believe this is for Rnw or Rrst document. see ?knit2pdf.

Thank you.

@cderv Thank you for the quick explanation. Yeah, it works when I copy the 'references.bib' file to the folder where the '.Rmd' file lives. However, I still find it puzzling why rmarkdown/pandoc does not find the Documentation/references.bib file. In fact, I set the Evaluate Chunks in Directory option to Project and I expect that to work. I am missing something here? Thank you.

Originally posted by @eyayaw in #1268 (comment)

@cderv
Copy link
Collaborator Author

cderv commented Dec 17, 2020

@eyayaw I opened a new issue with this to have a more dedicated place to look into this. You will be able to provide a reproducible examples, or at least more details on how your project is structured and what is the content of your files.

As reminder, you have an issue guide to follow: https://yihui.org/issue/. It is better to open new issues when you're not sure the problem you encounter is exactly the same as the one in which you are posting. And better to ask question on other places than Github issues.

Anyway, as hints, here is my understanding of your issue:

I believe this RStudio option you used is confusing. It will change the working directory for your code chunk evaluation by knitr inside your R Markdown document. However, it will not change the directory from which rmarkdown::render() works and will run Pandoc from - it will still be the input directory, and the output will still be generated in the input directory too, not in the project dir. It means pandoc will use path relatively to the input directory, if you provide relative path.

That means

bibliography: Documentations/packages.bib

will be looked into the input dir. If you don't want to have the file in the same directory, you need to use absolute path. The here 📦 can help you to generate an absolute path from a relative project path. Using inline R chunk in the Rmd will render as text in the md that Pandoc will convert (https://here.r-lib.org/articles/rmarkdown.html) Example in your yaml

bibliography: '`r here::here("Documentations/packages.bib")`'

Hope it helps.

@cderv cderv added the question general questions - not an issue label Dec 17, 2020
@cderv
Copy link
Collaborator Author

cderv commented Jan 6, 2022

As there was no activity on this following the comment, I'll close this.

@eyayaw Please feel free to reopen or open a new issue if there is still something not clear.

Thanks

@cderv cderv closed this as completed Jan 6, 2022
@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 Jul 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question general questions - not an issue
Projects
None yet
Development

No branches or pull requests

1 participant