I am currently working on a continuous integration setup for R packages developed by our company. We have one Jenkins project for each R package and a corresponding library for each project.
I already defined a logic that installs all dependencies of the package into the project library. Now i want to define a check stage which basically runs
devtools::check("${PROJECT_DIR}/pkg")
but only use the project library for dependencies. I tried to use the callr
package in the following manner.
callr::r(
function(...) {
devtools::check(...)
),
args = list("${PROJECT_DIR}/pkg"),
libpath = "${PROJECT_DIR}/lib"
)
However, the check process is still able to find packages which are not installed in libpath
. Is there a way to make sure that only "${PROJECT_DIR}/lib"
is used during the build stage?
So far, I have tried the following to no avail
callr()
with thelibpath
argumentwithr::with_libpaths
with thenew
argument- Look through the documentation in
devtools::check
andR CMD BUILD
for appropriate parameters - Use
.libPaths("${JOB_DIR}/lib")
Here is a repex to explain the unexpected behavior of callr
. I expect an error in line 3.
find.package("ggplot2", .libPaths()[1])
#> Error in find.package("ggplot2", .libPaths()[1]): there is no package called 'ggplot2'
callr::r(function() { ggplot2::vars() }, libpath = .libPaths()[1])
#> named list()
find.package("ggplot2", .libPaths()[2])
#> [1] "/data/R/3.5.3/lib/R/library/ggplot2"
callr::r(function() { ggplot2::vars() }, libpath = .libPaths()[2])
#> named list()