I am attempting to use the pool package in my Shiny golem application.
I have slightly updated the default golem-config.yml:
default:
golem_name: mygolem
golem_version: 0.0.0.9000
app_prod: no
default_programs: !expr c(1:10000)
db_host: mydata.us-west-2.rds.amazonaws.com
db_name: efs
dev:
golem_wd: !expr here::here()
default_programs: !expr c(1:10000)
db_host: mydata-new.us-west-2.rds.amazonaws.com
db_name: efs
production:
default_programs: !expr c()
db_host: mydata-new.us-west-2.rds.amazonaws.com
db_name: efs
app_prod: yes
In order to use pool, I have a R/globals.R file that contains a single call:
pool <- pool::dbPool(
RMySQL::MySQL(),
dbname = get_golem_config("db_name"),
host = get_golem_config("db_host"),
username = Sys.getenv("DB_USERNAME"),
password = Sys.getenv("DB_PASSWORD")
)
My .Renviron file is in my project root folder.
I can not figure out why I keep getting this error when I deploy to Shinyapps.io:
Config file not found in current working directory or parent directories
It builds locally fine. And, when I hard replace dbname and host with the actual values from the golem-config.yml file, it builds and deploys just fine.
So there is something about the get_golem_config() function that is causing this error. Here is my function:
get_golem_config <- function(value, config = Sys.getenv("R_CONFIG_ACTIVE", "default"), use_parent = TRUE) {
config::get(value = value,
config = config,
file = app_sys("golem-config.yml"),
use_parent = use_parent
)
}
app_sys is a simple wrapper around system.file with the package parameter pre-populated by my own package name.
I think it has something to do with the config::get, because when I edit my globals.R file to be:
pool <- pool::dbPool(
RMySQL::MySQL(),
dbname = config::get(value = "db_name",
config = Sys.getenv("R_CONFIG_ACTIVE", "default"),
file = app_sys("golem-config.yml"),
use_parent = TRUE
),
host = config::get(value = "db_host",
config = Sys.getenv("R_CONFIG_ACTIVE", "default"),
file = app_sys("golem-config.yml"),
use_parent = TRUE
),
username = Sys.getenv("DB_USERNAME"),
password = Sys.getenv("DB_PASSWORD")
)
The error returns.