Determines whether the current R session is running in a hosted environment such as Google Colab, VS Code, Kubernetes, or RStudio Server (non-localhost).
Value
A logical value: TRUE if running in a hosted session (Google Colab,
VS Code, Kubernetes, or remote RStudio Server), FALSE otherwise.
Details
This function checks for (in order):
Option override: if
azr.hostedoption is set, returnsisTRUE()of its valueGoogle Colab: presence of the
COLAB_RELEASE_TAGenvironment variableVS Code: presence of the
VSCODE_INJECTIONorVSCODE_PROXY_URIenvironment variableKubernetes: presence of the
KUBERNETES_SERVICE_HOSTenvironment variableRStudio Server:
RSTUDIO_PROGRAM_MODEis "server" andRSTUDIO_HTTP_REFERERdoes not contain "localhost"
Examples
if (is_hosted_session()) {
message("Running in a hosted environment")
}
