Skip to content

Commit

Permalink
respect libpaths
Browse files Browse the repository at this point in the history
  • Loading branch information
mjz1 committed Feb 20, 2024
1 parent df891c4 commit 09f0b4e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/rscript.R
Expand Up @@ -69,10 +69,10 @@ tcq <- function(...) {
#' Creates an R script
#' @noRd
#' @param pkgs A named list of R packages to load.
load_packages <- function(pkgs, tmp_path, job_name) {
load_packages <- function(pkgs, tmp_path, job_name, libPaths) {

# For testing purposes, the instalation of the package is somewhere else
sprintf("library(%s, lib.loc = \"%s\")", names(pkgs), unlist(pkgs))
# For testing purposes, the installation of the package is somewhere else
sprintf("library(%s, lib.loc = %s)", names(pkgs), paste0("c('", paste(libPaths, collapse = "', '"), "')"))

}

Expand Down Expand Up @@ -232,7 +232,7 @@ new_rscript <- function(
)

# We only load packages if loaded...
pkgs <- load_packages(pkgs, tmp_path = tmp_path, job_name = job_name)
pkgs <- load_packages(pkgs, tmp_path = tmp_path, job_name = job_name, libPaths = libPaths)
if (length(pkgs)) {
env$append("message(\"[slurmR info] Loading packages ... \")", wrap = FALSE)
env$append(pkgs)
Expand Down

1 comment on commit 09f0b4e

@gvegayon
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put this as a PR and see if the tests pass?

Please sign in to comment.