yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.36k stars 873 forks source link

write_bib producing NULL in knitr 1.45 #2334

Closed HedvigS closed 3 months ago

HedvigS commented 3 months ago

By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.


I am struggling with knitr::write_bib() for certain packages, for example nFactors. When I run write_bib for nFactors on one of my machine that has knitr 1.43, it works. But, on my other machine where I have knitr 1.45 it breaks - it produces nothing. I have included the console output for the breaking with knitr 1.45 below.


> library(knitr)
> 
> citation("nFactors")
To cite package ‘nFactors’ in publications use:

  Raiche G, Magis D (2022). _nFactors: Parallel Analysis and Other Non Graphical Solutions to the Cattell Scree
  Test_. R package version 2.4.1.1, <https://CRAN.R-project.org/package=nFactors>.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {nFactors: Parallel Analysis and Other Non Graphical Solutions to the
Cattell Scree Test},
    author = {Gilles Raiche and David Magis},
    year = {2022},
    note = {R package version 2.4.1.1},
    url = {https://CRAN.R-project.org/package=nFactors},
  }

ATTENTION: This citation information has been auto-generated from the package DESCRIPTION file and may need manual
editing, see ‘help("citation")’.
> 
> citation("knitr")
To cite package ‘knitr’ in publications use:

  Xie Y (2023). _knitr: A General-Purpose Package for Dynamic Report Generation in R_. R package version 1.45,
  <https://yihui.org/knitr/>.

  Yihui Xie (2015) Dynamic Documents with R and knitr. 2nd edition. Chapman and Hall/CRC. ISBN 978-1498716963

  Yihui Xie (2014) knitr: A Comprehensive Tool for Reproducible Research in R. In Victoria Stodden, Friedrich Leisch
  and Roger D. Peng, editors, Implementing Reproducible Computational Research. Chapman and Hall/CRC. ISBN
  978-1466561595

To see these entries in BibTeX format, use 'print(<citation>, bibtex=TRUE)', 'toBibtex(.)', or set
'options(citation.bibtex.max=999)'.
> 
> xfun::session_info('knitr')
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.4.1, RStudio 2023.12.1.402

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

time zone: Europe/Berlin
tzcode source: internal

Package version:
  evaluate_0.21   graphics_4.3.3  grDevices_4.3.3 highr_0.10      knitr_1.45      methods_4.3.3   stats_4.3.3     tools_4.3.3    
  utils_4.3.3     xfun_0.39       yaml_2.3.7     
> 
> knitr::write_bib("nFactors")
HedvigS commented 3 months ago

I've solved the immediate issue for me by using groundhogr to load an older version of knitr.

atusy commented 3 months ago

As far as I tried, it seems the issue is fixed by https://github.com/yihui/knitr/issues/2304

Would you try the dev version with remotes::install_github("yihui/knitr")?

yihui commented 3 months ago

I think @atusy is right.

I'm also planning to make a new knitr release to CRAN in the next few days, so hopefully you can use the new CRAN version.

HedvigS commented 3 months ago

As far as I tried, it seems the issue is fixed by #2304

Would you try the dev version with remotes::install_github("yihui/knitr")?

I saw that issue and I thought about that, but the citation does have a URL-field. If this is fixed in future releases that'd be amazing :). I'd have to update groundhog date again, but hopefully that won't break anything else.

HedvigS commented 3 months ago

Hurray, the most recent github install works!


> library(knitr)
> knitr::write_bib("nFactors")
@Manual{R-nFactors,
  title = {nFactors: Parallel Analysis and Other Non Graphical Solutions to the
Cattell Scree Test},
  author = {Gilles Raiche and David Magis},
  year = {2022},
  note = {R package version 2.4.1.1},
  url = {https://CRAN.R-project.org/package=nFactors},
}

> xfun::session_info('knitr')
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.4.1, RStudio 2023.12.1.402

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

Package version:
  evaluate_0.23   graphics_4.3.3  grDevices_4.3.3 highr_0.10      knitr_1.45.14   methods_4.3.3   stats_4.3.3     tools_4.3.3    
  utils_4.3.3     xfun_0.43       yaml_2.3.8