You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Environment detection helpers for Workbench and Connect #290
I'd love generalizable versions of rstudioapi::isAvailable() that can detect in which environment code is running to then gate logic (e.g., authentication patterns that differ b/w Workbench and local), to prevent ad hoc picking of env vars (that may drift over product versions).
A starting point translated from some wrappers I've used:
# duplicative of `rstudioapi::IsAvailable()` but avoids circular logic if `rstudioapi` is not installed
get_env_rstudio_ide <- function() {
Sys.getenv("RSTUDIO_PROGRAM_MODE")
}
is_env_rstudio_ide_desktop <- function() {
get_env_rstudio_ide() == "desktop"
}
is_env_rstudio_ide_workbench <- function() {
get_env_rstudio_ide() == "server"
}
is_env_rstudio_ide <- function() {
is_env_rstudio_ide_desktop() || is_env_rstudio_ide_workbench()
}
is_env_connect <- function() {
# have also used `USER` or `USERNAME`
Sys.getenv("LOGNAME") == "rstudio-connect"
}
# Processes executing on a server (Workbench or Connect) ----
is_env_server <- function() {
is_env_rstudio_ide_workbench() || is_env_connect()
}
Activity