Reputation: 55695
I am interested in excluding two directories inst\docs
and inst\examples
while building and installing the package. I know that an easy way out is just to move docs
and examples
to the root directory and they won't get installed. However, I want to keep them in inst
for other reasons.
I tried adding the following lines to .Rbuildignore
inst/docs
inst/examples
I use RStudio v 0.97 and devtools
to build and install the package from source. However, when I do that, I still see that inst\docs
and inst\examples
get installed. I tried different regexes, but nothing seemed to work.
Am I doing something wrong?
Upvotes: 54
Views: 17943
Reputation: 4077
I find that I obtain the most consistent behaviour when treating each line of the .Rbuildignore
file as a regular expression.
In your case I would manually create a text file in the root directory of the project named .Rbuildignore
with the contents
^inst/docs
^inst/examples
The expression ^inst/docs
matches any file or folder that begins with (^
) the string inst/docs
. usethis::use_build_ignore()
adds a trailing $
to each expression, which I have found can cause files within these folders not to be captured by the pattern (and thus not being ignored).
Upvotes: 6
Reputation: 84529
You can do
usethis::use_build_ignore(c("yourfolder1", "yourfolder2", "yourfile"))
Upvotes: 36
Reputation: 1285
Just to update, as of the latest versions, devtools::use_build_ignore
has been moved to:
usethis::use_build_ignore(c("yourfolder1", "yourfolder2", "yourfile"))
Upvotes: 5
Reputation: 5249
An old post but it still seems to be an issue when building binary packages. The following hack seems to work though (i.e., build source package and then build binary from that source package).
f <- devtools::build("mypackage")
system(paste0("R CMD INSTALL --build ", f))
Upvotes: 3
Reputation: 61933
This appears to be an issue with RStudio. Using install
from the devtools package seems to cause the folders to be ignored. Building and installing directly from the command line also seems to cause the folders to be ignored. The 'Build & Reload' button in RStudio, however, seems to not take into account the .Rbuildignore for those folders.
Upvotes: 20