browseVignettes(mypackage) saying no vignettes found

I always have this same vignette problem when I am building packages on RStudio that I host on GitHub. The reason is that in that situation I want the vignettes files in the inst/doc folder. If you build to a .tar.gz (which is what you'd upload to CRAN), then the vignettes files are put there, but if you build and install using Install and Restart on RStudio's build tab, then the files won't be in the inst/doc folder even if you have specified for Roxygen to rebuild your vignettes on Install and Restart. It rebuilds them in the vignettes folder but doesn't copy them to inst/doc.

Here is my workflow.

  • Prepare my vignette Rmds in the vignettes folder. Use the template in RStudio.
  • Use this code to build them and put them in the inst folder.
tools::buildVignettes(dir = ".", tangle=TRUE)
dir.create("inst/doc")
file.copy(dir("vignettes", full.names=TRUE), "inst/doc", overwrite=TRUE)
  • Then push the changes to GitHub. Also this will mean that when you use Install and Restart on the Build tab, your vignettes will now be there too (e.g. they'll show up on browseVignettes().

Be aware that RStudio's default Check package behavior on the Build tab is to delete your inst/doc folder. If you don't notice and push changes to GitHub, you've just deleted all your vignettes from your GitHub package. They are still there in the vignettes folder but you'd have to use the build_vignettes=TRUE in install_github() to see them. The deletion is happening because you need to use devtools:check(".", vignettes=FALSE) and there is no way to set that from the Build Options in RStudio. But you can uncheck the use devtools package functions and stop RStudio from using devtools. You may want to add --no-manual to the R CMD check options box since building the manual can be time consuming.

Note the devtools functions are not helpful, I find, since they are for a different workflow more oriented to submitting packages to CRAN via a .tar.gz file or if you are not working via the RStudio build platform.

devtools::build_vignettes() is going to rebuild your vignettes but put them at the base level in doc which is not where you need them. It will also create the Meta folder which you don't need.

devtools::build() will make a tar.gz file with the vignette files in inst/doc but you don't want the tar.gz for your GitHub package repo or for the Install and Restart button on the Build tab. You want the inst/doc folder filled with the vignette files.

2 Likes