From 930a989080bdf289ba4fac108a6607b36033beb4 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Fri, 6 Sep 2024 19:09:18 +0000 Subject: [PATCH] added error handling around processx::run("squeue"). Will throw warning and likely errors because option never gets set. --- R/zzz.R | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index fc8db21..aaafa6b 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -4,14 +4,23 @@ } .onLoad <- function(libname, pkgname) { - processx_output <- processx::run("squeue", args = "--version") - if (processx_output$status != 0) { - warning("squeue not installed correctly") - } else { - # stdout format is "slurm major.minor.patch/n" - version <- strsplit(processx_output$stdout," ")[[1]][[2]] %>% - trimws() %>% - package_version() - options("squeue.version" = version) + result <- tryCatch( + {processx::run("squeue", args = "--version")}, + error = function(e) { + message("Warning: 'squeue' command not found or failed to run.") + return(NULL) + } + ) + + if (!is.null(result)) { + if (result$status != 0) { + warning("squeue not installed correctly") + } else { + # stdout format is "slurm major.minor.patch/n" + version <- strsplit(result$stdout," ")[[1]][[2]] %>% + trimws() %>% + package_version() + options("squeue.version" = version) + } } }