check-scalar-isCondaEnabled: Is conda enabled (active) in the current R session?

check-scalar-isCondaEnabledR Documentation

Is conda enabled (active) in the current R session?

Description

Is conda enabled (active) in the current R session?

Usage

isCondaEnabled(ignoreBase = TRUE)

Arguments

ignoreBase

logical(1). If TRUE, don't consider conda to be "active" if only the base environment is loaded. This is useful to avoid some false-positive situations when handling the main conda activate script in shell sessions.

Details

This checks CONDA_DEFAULT_ENV and CONDA_SHLVL system environment variables internally.

Value

TRUE on success; FALSE on failure, with cause set.

Note

Updated 2021-08-19.

Examples

vars <- c("CONDA_DEFAULT_ENV", "CONDA_SHLVL")
Sys.unsetenv(vars)

## TRUE ====
Sys.setenv(
    "CONDA_DEFAULT_ENV" = "test",
    "CONDA_SHLVL" = "2"
)
isCondaEnabled()
Sys.unsetenv(vars)

Sys.setenv(
    "CONDA_DEFAULT_ENV" = "base",
    "CONDA_SHLVL" = "1"
)
isCondaEnabled(ignoreBase = FALSE)
Sys.unsetenv(vars)

## FALSE ====
isCondaEnabled()

Sys.setenv(
    "CONDA_DEFAULT_ENV" = "base",
    "CONDA_SHLVL" = "1"
)
isCondaEnabled(ignoreBase = TRUE)
Sys.unsetenv(vars)

acidgenomics/goalie documentation built on Dec. 11, 2023, 11:36 p.m.