crsh / citr

RStudio Addin to Insert Markdown Citations
Other
407 stars 46 forks source link

Error in finding path to .bib file #52

Closed bblodfon closed 5 years ago

bblodfon commented 5 years ago

Hi,

I am using bookdown (0.12) for writing my thesis and I want to include the citations in an automated way using your package citr.

I have a file called references.bib which I exported from Mendeley and includes the citations. The index.Rmd file (which is on the /home/john/repos/my-phd-thesis dir) has in the yaml front mater the line: bibliography: references.bib. When I press the Rstudio addin button 'Insert Citations' I get this error:

> citr:::insert_citation()
Error in tools::file_path_as_absolute(file.path(rmd_path, yaml::yaml.load(yaml_front_matter)$bibliography)) : 
  file '/home/john/repos/my-phd-thesis/index.Rmd/references.bib' does not exist

Should be something on my part (config, etc.) or just a bug I don't know :) Let me know if you need something else from my part. The full code of the thesis is here

neurotroph commented 5 years ago

After updating to version 0.3.1 I run into a similar error:

> citr:::insert_citation()
Error in tools::file_path_as_absolute(file.path(rmd_path, yaml::yaml.load(yaml_front_matter)$bibliography)) : 
  'x' must be a single character string

In my index.Rmd I have multiple bibliography references:

bibliography: ["references.bib","../references.bib"]

Removing either leads to the same error as @bblodfon posted.

Seems to be a bug in the most recent version on both CRAN and GitHub. In particular with the most recent commit: https://github.com/crsh/citr/commit/de99c73abf17bd3e447034def0c58aef9e06d26e#diff-4744dbfad92f5b61198585e92bc7af8d

Session Info:

R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2       citr_0.3.1       compiler_3.6.0   pillar_1.4.2     later_0.8.0      tools_3.6.0      digest_0.6.20    packrat_0.5.0    evaluate_0.14    tibble_2.1.3     gtable_0.3.0     pkgconfig_2.0.2 
[13] rlang_0.4.0      shiny_1.3.2      rstudioapi_0.10  curl_4.0         yaml_2.2.0       xfun_0.8         stringr_1.4.0    dplyr_0.8.3      knitr_1.24       tidyselect_0.2.5 grid_3.6.0       glue_1.3.1      
[25] R6_2.4.0         rmarkdown_1.14   bookdown_0.12    purrr_0.3.2      ggplot2_3.2.1    magrittr_1.5     scales_1.0.0     promises_1.0.1   ggthemes_4.2.0   htmltools_0.3.6  assertthat_0.2.1 mime_0.7        
[37] xtable_1.8-4     colorspace_1.4-1 httpuv_1.5.1     stringi_1.4.3    miniUI_0.1.1.1   lazyeval_0.2.2   munsell_0.5.0    crayon_1.3.4    
crsh commented 5 years ago

Hi, thanks for reporting this so promptly and sorry for the delayed response. I just pushed a fix for both problems. If it resolves the issue I'll resubmit to CRAN as soon as possible. Feedback would be most welcome.

neurotroph commented 5 years ago

Problem seems to fixed through your last commit. Loading the citr window, adding items (also from Zotero) etc., works fine now.

bblodfon commented 5 years ago

Everything ok from my side as well!

crsh commented 5 years ago

Excellent, thank you! Will resubmit to CRAN tonight.