Search code examples
rcran

R CMD build leaves compiled .o files in src folder


I am one of the author of the R package xgboost. When I tried to pack it with R CMD build xgboost, there are 5 new compiled .o files inside src/.

I double checked that these files are not in the directory before. And strangely, this problem disappears when I run R CMD build --no-build-vignettes xgboost. I suspect there are something related to the process of compiling the vignettes. However we don't want to sacrifice the vignettes for it.

How can this be fixed? Thanks!

NOTE: To reproduce the problem, please run the following command in your console:

git clone https://github.com/tqchen/xgboost && cd xgboost && make Rpack

where make Rpack is a combination of file operations that move files to the correct places and R CMD operations. Edit the Rpack part in Makefile to control this flow.


Solution

  • OK after some attempts the following solution works for me:

    1. Create a file named .Rbuildignore
    2. Fill it with the file names (patterns) that you don't need.

    An example is this file: https://github.com/dmlc/xgboost/blob/master/R-package/.Rbuildignore