Hello!
We have a dev and prod RSC (RStudio Connect) that we deploy our apps to. There are some functions that operate differently depending on which environment the app is running on. I would like to add a simple environment variable that is accessible across all projects to each environment.
Example: On RSC dev if I ran Sys.getenv("RSC_ENV")
it would return the value "dev". If I ran Sys.getenv("RSC_ENV")
within RSC prod it would return the value "prod".
I want to avoid having to add a secure environment variable to every project one by one. Is this possible? I found the following article, Environment variables on RStudio Connect – RStudio Support, I think does what I want, but I do not have access to execute the steps and wanted to see if this is the best route for setting environment variables that can be accessed by applications running on RSC.
Example from article modified; would this get me the result I want in RSC dev? Assuming I followed the article's instructions.
#!/bin/bash
echo arguments: "$@" >&2
echo >&2
export RSC_ENV="dev"
exec "$@"
So in my R code Sys.getenv("RSC_ENV")
would return "dev".
I appreciate any insight on global environment variables in RSC or another direction for identifying my environment!