diff --git a/R/epidatr-package.R b/R/epidatr-package.R index 1b22c9e..495368d 100644 --- a/R/epidatr-package.R +++ b/R/epidatr-package.R @@ -8,8 +8,14 @@ "_PACKAGE" .onLoad <- function(libname, pkgname) { - cache_environ$use_cache <- Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE) - cache_environ$use_cache <- (cache_environ$use_cache == "TRUE") + cache_environ$use_cache <- as.logical(Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE)) + if (is.na(cache_environ$use_cache)) { + cli::cli_warn( + "Failed to read EPIDATR_USE_CACHE environment variable. + Should be a logical. Defaulting to FALSE." + ) + cache_environ$use_cache <- FALSE + } if (cache_environ$use_cache) { set_cache(startup = TRUE) }