Skip to content

Commit 9677f2e

Browse files
authored
[setup-r-dependencies]: set R_LIBS_USER if unset (#896)
* [setup-r-dependencies]: set R_LIBS_USER if unset * Cannot use env.R_LIBS_USER directly in R Because it uses backslashes on Windows, which means invalid escapes in R. * Message about R_LIBS_USER * Add NEWS for R_LIBS_USER setting [ci skip]
1 parent e0a5ffd commit 9677f2e

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
unchanged, on all R versions. To avoid using a P3M snapshot on R 3.6.x,
1515
set the `RSPM_PIN_3_6` environment variable to `false`.
1616

17+
* `[setup-r-dependencies]` now always sets the `R_LIBS_USER` GitHub
18+
environment variable, so it can be used without `[setup-r]` or without
19+
setting it manually (#881).
20+
1721
* The example workflows now use their file names as workflow names.
1822
This is to make it easier to match worflow runs to workflow files.
1923
Most of the the `check-*` workflows use `R-CMD-check.yaml`, however,

setup-r-dependencies/action.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ runs:
7474
message("R_LIBS_SITE is already set to ", lib)
7575
cat(sprintf("R_LIB_FOR_PAK=%s\n", strsplit(lib, .Platform$path.sep)[[1]][[1]]), file = Sys.getenv("GITHUB_ENV"), append = TRUE)
7676
}
77+
if (nchar("${{ env.R_LIBS_USER && 'ok' || '' }}") == 0) {
78+
message("R_LIBS_USER GH env var is unset, setting now: ", Sys.getenv("R_LIBS_USER"))
79+
cat(sprintf("R_LIBS_USER=%s\n", Sys.getenv("R_LIBS_USER")), file = Sys.getenv("GITHUB_ENV"), append = TRUE)
80+
} else {
81+
message("R_LIBS_USER GH env var is already set: ", Sys.getenv("R_LIBS_USER"))
82+
}
7783
cat("::endgroup::\n")
7884
shell: Rscript {0}
7985

0 commit comments

Comments
 (0)