From 95fc0a4d5f3a731583eec6f5c3fdab73f3634715 Mon Sep 17 00:00:00 2001 From: Andreas Gammelgaard Damsbo Date: Thu, 12 Mar 2026 11:32:06 +0100 Subject: [PATCH] fix: trying to fix launching with globals --- R/hosted_version.R | 2 +- R/launch_FreesearchR.R | 19 +++++++++++++++---- man/launch_FreesearchR.Rd | 8 ++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/R/hosted_version.R b/R/hosted_version.R index 2306a9f6..b15a5737 100644 --- a/R/hosted_version.R +++ b/R/hosted_version.R @@ -1 +1 @@ -hosted_version <- function()'v26.3.3-260311' +hosted_version <- function()'v26.3.3-260312' diff --git a/R/launch_FreesearchR.R b/R/launch_FreesearchR.R index 99046649..a789f185 100644 --- a/R/launch_FreesearchR.R +++ b/R/launch_FreesearchR.R @@ -43,14 +43,15 @@ launch_FreesearchR <- function(include_globalenv = TRUE, ## Helper to set env variables get_config <- function(var_name, default = NULL) { - # First check environment variables (set by Docker) - val <- Sys.getenv(var_name, unset = NA) + val <- Sys.getenv(var_name, unset = NA_character_) - if (!is.na(val) && nzchar(val)) { + # Only use env var if it is explicitly set and non-empty + if (!is.na(val) && nzchar(trimws(val))) { + if (is.logical(default)) return(to_logical(val)) + if (is.numeric(default)) return(as.numeric(val)) return(val) } - # Fall back to default (can be overridden when launching from R) if (!is.null(default)) { return(default) } @@ -58,6 +59,16 @@ get_config <- function(var_name, default = NULL) { stop(paste("Required config variable not set:", var_name)) } +to_logical <- function(x) { + result <- switch(tolower(trimws(as.character(x))), + "true" = , "1" = , "yes" = TRUE, + "false" = , "0" = , "no" = FALSE, + NA + ) + if (is.na(result)) stop(paste("Cannot coerce to logical:", x)) + result +} + ## File loader - based on the module, uses hard coded default values load_file <- function(path) { diff --git a/man/launch_FreesearchR.Rd b/man/launch_FreesearchR.Rd index e052ba7b..2ab6c607 100644 --- a/man/launch_FreesearchR.Rd +++ b/man/launch_FreesearchR.Rd @@ -5,7 +5,7 @@ \title{Easily launch the FreesearchR app} \usage{ launch_FreesearchR( - inlcude_globalenv = TRUE, + include_globalenv = TRUE, data_limit_default = 1000, data_limit_upper = 1e+05, data_limit_lower = 1, @@ -13,6 +13,9 @@ launch_FreesearchR( ) } \arguments{ +\item{include_globalenv}{flag to include global env (local data) as option +when loading data} + \item{data_limit_default}{default data set observations limit} \item{data_limit_upper}{data set observations upper limit} @@ -20,9 +23,6 @@ launch_FreesearchR( \item{data_limit_lower}{data set observations lower limit} \item{...}{passed on to \code{shiny::runApp()}} - -\item{include_globalenv}{flag to include global env (local data) as option -when loading data} } \value{ shiny app