The correct use of devtools and/or RStudio with respect to .Rbuildignore

The thing that works for me is to use devtools::build to make a source package, then install.packages.

devtools::build() %>% 
  install.packages(repos = NULL, type = "source")

Using devtools::build(binary = TRUE) does not work, since it calls R CMD INSTALL rather than R CMD build, which ignores .Rbuildignore files. Likewise, RStudio's "Build & Reload" button uses R CMD INSTALL.


I was encountering a similar problem when using devtools::check_win_devel() and devtools::release().

For consistent behaviour, I have found that it helps to use regular expressions for all entries in .Rbuildignore. This file would then become:

^.*\.Rproj$
^\.Rproj\.user$
^inst/examples
^inst/prof
^man\-roxygen
^tests

The directories are then ignored.