Created
October 22, 2015 12:33
-
-
Save famuvie/163be4d05b7953a355ed to your computer and use it in GitHub Desktop.
Use of install.libs.R in an R package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Create a minimal buildable package | |
library(devtools) | |
create('testpkg') | |
## Write src/install.libs.R | |
dir.create('testpkg/src') | |
test.file <- path.expand('~/testfile.txt') | |
diag.lines <- c( | |
deparse(quote(stop('This should break the installation'))), | |
deparse(quote(file.create(test.file))) | |
) | |
writeLines(diag.lines, | |
'testpkg/src/install.libs.R') | |
## Install package | |
## also tried manually with R CMD INSTALL | |
install('testpkg') | |
## The installation did not break | |
## nor the file has been created | |
file.exists('~/testfile.txt') # FALSE | |
## Cleanup | |
remove.packages('testpkg') | |
unlink('testpkg', recursive = TRUE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to Duncan Murdoch from R-package-devel mailing list for the answer:
The problem with the sample is that it has no
files in src that trigger processing: those would be Makefile,
Makefile.win, Makevars, or source files in supported languages.
If the real example doesn't have any of these (e.g. because it is just
copying a pre-compiled file from somewhere; not something you should do
in a CRAN package, but maybe reasonable in a local one), then the
easiest workaround is just to add an empty Makevars file.