paleolimbot / rbbt

R Interface to the Better BiBTex Zotero Connector
145 stars 26 forks source link

Error: Use `overwrite = TRUE` to overwrite file #29

Closed oustella closed 2 years ago

oustella commented 2 years ago

Hi - here's what I am trying to do. I have several chapters of my thesis in separate rmd files. So I figured once all the citations are added, I need to run rbbt::bbt_update_bib to make sure they all show up in one bib file for knitting. Not sure if I can add multiple rmd paths in one call function call, so I tried calling the function in each rmd file but turning out overwrite=FALSE so the new entries get appended. When I did this, I received the error message "Error: Use overwrite = TRUE to overwrite file at '/Users/username/Documents/Thesis/bib/_Thesis.bib'". I'd appreciate pointers to how to generate one bib file from multiple rmarkdown sources, if this is possible. Alternatively, I suppose I can generate one gigantic bib file from my entire Zotero library so this update step is not needed. I am on a Mac, using an iteration of the bookdown / thesisdown process to manage knitting. Thank you so much.

bwiernik commented 2 years ago

I believe overwrite = FALSE doesn't append, only errors when the file exists.

I believe that you should call the rbbt fucntion only once in your index Rmd file. The way bookdown works is it will first compile all the sub-documents into one, then render it. So you only need to construct the bibliography file once.

One other thing--you should export to .YAML or .json format for your bibliography file, not .bib. RMarkdown/pandoc uses CSL format data, not BibTeX data. BibTeX data needs to be converted to CSL anyway, and this isn't a 100% accurate process

oustella commented 2 years ago

Ah I see. overwrite = FALSE acts as a safeguard to prevent an existing bib file from getting updated. It is not designed for appending.

Thanks for the pointers on bookdown. I created a thesis.json to be my new bibliography source/destination, then added the following to my index.Rmd file. It worked exactly as intended - adding the missing citations to the final bibliography by going back in the larger Zotero library to retrieve them. This is great because now I don't have to worry about maintaining all references in one collection for export - even if I have a paper in another collection not originally exported, rbbt can still find it as long as it is Zotero.

if(!require(rbbt))
  remotes::install_github("paleolimbot/rbbt")
library(rbbt)
rbbt::bbt_update_bib("/Users/username/Documents/Thesis/thesis.Rmd")  # Specify the source Rmd file to be the final document, not `index.Rmd`.

I'm closing this issue. Thanks so much again.