devtools check error with vignette, but vignette can be knitted without problem

I'm trying to prepare my package for CRAN, and running devtools check.

One of my vigentte met error:

checking re-building of vignette outputs ... WARNING
Error(s) in re-building vignettes:
...
--- re-building 'package_usage.Rmd' using rmarkdown
Quitting from lines 177-180 (package_usage.Rmd)
Error: processing vignette 'package_usage.Rmd' failed with diagnostics:
All items in j=list(...) should be atomic vectors or lists. If you are trying something like j=list(.SD,newcol=mean(colA)) then use := by group instead (much quicker), or cbind or merge afterwards.
--- failed re-building 'package_usage.Rmd'

However the vignette itself can be knitted without any problem, and the function caused error has been used in my package for a long time without any problem.

I tried to reproduce the error but cannot find how to do it. It looks like devtools used some specific mode to run the code...

Some internet search mentioned to use rmarkdown::render as vignette engine, but I tried to use it then vigenette cannot be built.

How can I reproduce the error reported?

1 Like

I'm guessing that you've solved the issue now, but your post was coming up as the top hit while I was trying to solve the same problem. I was finding that my package's vignette would build when I hit 'Knit' or used devtools::build_vignettes() but it would crash with an error when I used devtools::check(). As you hinted at, I managed to solve it by switching from knitr to rmarkdown as the vignette builder. The changes that I had to make to do this were:

DESCRIPTION:
VignetteBuilder: knitr -->VignetteBuilder: rmarkdown
Suggests: knitr, BiocStyle --> Suggests: knitr, BiocStyle, rmarkdown

VIGNETTE:
%\VignetteEngine{knitr::rmarkdown} --> %\VignetteEngine{rmarkdown::render}

With those changes made, devtools::check() works fine. It seems likely that there is a bug somewhere in either knitr or devtools, but not really clear to me which. If any of the developers of those packages wants to try and fix it, I can point them at the relevant file on github.

1 Like