Closed LiNk-NY closed 7 months ago
Thanks Marcel. It'd be interesting to understand why R CMD build Biostrings
works on my laptop and all our build machines. Do you have any idea what setting they might be using on the r-universe builds that is needed to reproduce this error?
Could it be that the r-universe builds are using the wrong output_format
?
> rmarkdown::render("matchprobes.Rmd", output_format=rmarkdown::html_document())
processing file: matchprobes.Rmd
|. | 3%
Quitting from lines 2-50 (matchprobes.Rmd)
Error in `Biocpkg()`:
! could not find function "Biocpkg"
In the context of R CMD build
, the default output_format
should be used. This is the first format listed in the output:
section of the YAML frontmatter of the Rmd file e.g. BiocStyle::html_document
in the case of matchprobes.Rmd
. Then everything goes fine:
> rmarkdown::render("matchprobes.Rmd")
processing file: matchprobes.Rmd
output file: matchprobes.knit.md
/usr/bin/pandoc +RTS -K512m -RTS matchprobes.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output matchprobes.html --lua-filter /home/hpages/R/R-4.4.r85764/site-library/bookdown/rmarkdown/lua/custom-environment.lua --lua-filter /home/hpages/R/R-4.4.r85764/site-library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/hpages/R/R-4.4.r85764/site-library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --wrap preserve --variable bs3=TRUE --section-divs --table-of-contents --toc-depth 3 --template /tmp/RtmpOd3Uhx/BiocStyle/template.html --no-highlight --variable highlightjs=1 --number-sections --variable theme=bootstrap --css /home/hpages/R/R-4.4.r85764/site-library/BiocStyle/resources/html/bioconductor.css --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/RtmpOd3Uhx/rmarkdown-str51c7731edc82.html
Output created: matchprobes.html
However, I can see why it's admittedly an error to not explictely load the BiocStyle package at the beginning of the document before calling functions defined in the package. The fact that BiocStyle got loaded before rmarkdown::render()
even started to process the document is just a side effect of specifying the output format with output_format=BiocStyle::html_document()
. Relying on side effects like this is not good.
Anyways I have a feeling that omitting the library(BiocStyle)
call could be a fairly common issue. Poking around a little I see it in GenomicRanges/vignettes/GenomicRangesIntroduction.Rmd
, vsn/vignettes/A-vsn.Rmd
, and more... So the question is: Is it possible to catch this error via R CMD build
or R CMD check
? And if so, what is needed for that?
BTW how did you find out that Biostrings was failing on the r-universe builds? Did Jeroen Ooms contact you? I'm just gonna poke @jeroen here so maybe he can chime in.
@jwokaty Can we add this to the list of things to check in the context of the Sweave2Rmd project? An easy way to catch the problem is to try to render the document with rmarkdown::render(..., output_format="html_document")
(same as using rmarkdown::html_document()
it seems, but less typing). Thanks!
I think the command that was run should be visible in the GitHub Action log. However, I was able to track down the template here: if ! R_TEXI2DVICMD=emulation PDFLATEX=pdftinytex R_TESTS="/tmp/vignettehack.R" timeout 3600 R --no-init-file CMD build ${PKGDIR} --no-manual ${BUILD_ARGS} 1> >(tee stderr_build.log); then
I took a look at the Bioconductor page here and saw the errors: https://bioconductor.r-universe.dev/builds
Yes, there are other packages with the same error e.g., GenomeInfoDb
R-universe does indeed render vignettes into a custom style that matches the rest of the r-universe.dev website, in a similar fashion as pkgdown renders vignette's into a custom pkgdown theme, see buildtools::render_article().
But this should not affect the evaluation of R code. It is good practice to explicitly load BiocStyle if you use it, so I think this PR is probably the best solution.
I have also added a workaround in r-universe such that a custom package used in the output: pkg::html_document
yaml of the Rmd will be loaded, even if we actually override the output format to render the vignette.
Thanks for the explanation and the workaround!
Biocpkg
is used in the vignette butBiocStyle
is not loaded or referencedRE: https://github.com/r-universe/bioconductor/actions/runs/7684142017/job/20940280799