Skip to content

Instantly share code, notes, and snippets.

@famuvie
Created October 22, 2015 12:33
Show Gist options
  • Save famuvie/163be4d05b7953a355ed to your computer and use it in GitHub Desktop.
Save famuvie/163be4d05b7953a355ed to your computer and use it in GitHub Desktop.
Use of install.libs.R in an R package
## 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)
@famuvie
Copy link
Author

famuvie commented Oct 22, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment