Set test parameters
tmp <- file.path(
tempdir(),
util_rand_str()
)
dir.create(tmp)
on.exit(
unlink(
tmp,
recursive = TRUE
)
)
fn_renviron <- file.path(
tmp,
".Renviron"
)
# The library path is set to `{HOME}/R/{PLATFORM}-library/{R.VERSION}`
platform <- R.version[["platform"]]
major <- R.version[["major"]]
minor <- sub(
pattern = "^(\\d+)\\.\\d+$",
replacement = "\\1",
x = R.version[["minor"]]
)
version <- paste0(
major,
".",
minor
)
libpath <- file.path(
Sys.getenv("HOME"),
"R",
paste0(
platform
),
version
)
init <- dir.exists(libpath)
Run test
term_user_lib(
dir = tmp
)
#> User library path: /home/jek/R/x86_64-pc-linux-gnu/4.0
#> Added R_LIBS_USER="/home/jek/R/x86_64-pc-linux-gnu/4.0" to /tmp/RtmpZgmY2t/uuiKuQsF/.Renviron
unlink(
c(
fn_renviron,
tmp
),
recursive = TRUE
)
if (!init) {
unlink(
libpath,
recursive = TRUE
)
}