I have a script that works perfectly from the command line, but when I send it with qsub it fails with installing and loading packages.
Outside of qsub I run the command, and get the wanted results:
./myscript my.arg
To run with qsub I use:
qsub -cwd -m n -pe shared 32 -q my.q myscript my.arg
I get the following message of not being able to install packages (for example - not specific to this package)
Error: package or namespace load failed for ‘ggplot2’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘R6’
Execution halted
Even though they are already installed (and in any case the code includes a check-install function, so the script runs everywhere, without any prior installations needed)
I'm can not add the exact code here because it's an entire software that isn't published yet, but it works on all systems and this is the only issue that arises.
The general construct of the script sent is:
source('~/scripts/Software.R')
workin <- commandArgs(trailingOnly = TRUE)[1]
setwd(workin)
results <- function('../input_file.txt')
saveRDS(results, file = "../data_results.rds")
Where Software.R
includes the starting function:
list.of.packages <- c("data.table") # data.table is just an example
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if (length(new.packages)) install.packages(new.packages, repos = getCRANmirrors()[1,"URL"])
Thank you!
I also had a similar problem. I found out that when using qsub my working directory was different and so, files with relatives paths were not found. I used a cd to my working dir, or used full path to files and packages. I hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.