I'm trying to make R scripts run on a HPC cluster (with SLURM workload manager), which need a specific package that I installed in a personal directory since I can't install packages in the server-wide R installation. I tried to use .libPaths() and exporting a R_LIBS_USER variable in my bash scripts, but I can't get it to work. Here's my bash script generating the R scripts that i want to use. I always get the error that my package (EasyQC) cannot find its dependencies (the first being Cairo, which stops it immediately). Sorry for this post being a bit confused, I've been fighting with this for 2 days now and it's driving me a little mad. Thanks for your attention !
# Create R script to submit
cat > $HOME/output/easyQ/${input}_cleaning.R <<EOF
#!/usr/bin/env Rscript
HOME='$HOME'
source(paste0(HOME, "/analysis/input.R"))
.libPaths(R_LIBS_USER)
print(.libPaths())
library(EasyQC)
print("EasyQC loaded")
EasyQC(paste0(HOME, "/output/easyQ/${input}_cleaning.ecf"))
EOF
# Submit R script
echo "submit ${input}"
cat > $HOME/output/easyQ/${input}_cleaning.sh <<EOF
#!/bin/bash
#SBATCH --time=32:00:00
#SBATCH --mem=16G
#SBATCH --job-name=$input
#SBATCH --cpus-per-task=1
#SBATCH --chdir=$HOME/output/easyQ
#SBATCH --output=$HOME/output/log/%x.out
#SBATCH --error=$HOME/output/log/%x.err
# Load packages
module purge
module load r-light
export R_LIBS_USER=Path1:Path2
Rscript --no-save $HOME/output/easyQ/${input}_cleaning.R > $HOME/output/easyQ/${input}_cleaning_batch.log
EOF
I tried to use the .libPaths() function as well as lib.loc=Path when loading the libraries, but I cant really figure out how to use them.
I finallly fixed this by just loading another R moduel, with no real idea of how it worked.