[R-pkg-devel] R CMD check failure during vignette rebuilding

Konrad Rudolph konr@d@rudo|ph @end|ng |rom gm@||@com
Tue Apr 14 12:23:07 CEST 2020

I have a package vignette that reproducibly fails the second time
round in `R CMD check`, in the “checking re-building of vignette
outputs” step.

I have uploaded a small reprex to GitHub [1]. But in a nutshell the
vignette contains a subfolder `foo`, and a file `foo/bar`. And the
`test.rmd` vignette contains the following R code:

> newfile = file.path(getwd(), 'foo', 'baz')
> writeLines('baz', newfile)

This code causes `R CMD check` to delete the folder `foo` inside
`00_pkg_src/vignettes` after building the vignette, leading to the
following error message further down the line:

>   Error(s) in re-building vignettes:
>     ...
>   --- re-building ‘test.rmd’ using rmarkdown
>   Quitting from lines 8-10 (test.rmd)
>   Error: processing vignette 'test.rmd' failed with diagnostics:
>   cannot open the connection
>   --- failed re-building ‘test.rmd’

This seems to be due to the cleanup after building vignettes inside
`tools::buildVignette`, because creating a file inside a folder
changes the directory subfolder modification time (on POSIX-like
systems) so the whole folder is deleted in cleanup, rather than just
the file. Can I prevent this?

[1] https://github.com/klmr/vignettetest

Konrad Rudolph // @klmr

More information about the R-package-devel mailing list