Skip to contents

Returns the absolute path where an environment is expected under the data directory of its backend. It returns the path even if the environment does not exist yet.

Usage

get_env_dir(env_name = "condathis-env", method = "auto")

Arguments

env_name

Character string with the environment name. It must be a plain directory name that is valid on Linux, macOS and Windows:

  • Not empty, and not . or ...

  • Not starting with -, and not ending with ..

  • Without path separators, :, #, whitespace, control characters or <>"|?*.

  • Not a Windows device name, such as NUL or COM1 (see Environment names in create_env()).

Invalid values abort with class condathis_invalid_env_name. Functions that take only names reject an env_path() value with class condathis_env_path_read_only. run(), run_bin(), run_pipeline() and run_step() accept one.

method

Character string naming the backend. "auto" (the default) uses the backend that owns env_name when it exists, and otherwise the first available backend in getOption("condathis.backend_priority") order (see condathis-options). Any name from list_registered_backend_names() selects that backend, and "micromamba" is built in. The name of a backend whose package condathis knows, such as "rattler" of the rattlerthis package, also selects it. condathis loads the package on first use. It aborts with class condathis_backend_not_installed when the package is not installed. "native" is a deprecated alias for "micromamba" (warns once per session). If you name a backend other than the owner, functions that change the environment abort with class condathis_backend_mismatch. The others warn (condathis_backend_mismatch_warning) and use the owner. An environment found under several backends aborts with condathis_backend_ambiguous_env unless method names one of them. Invalid values abort with class condathis_invalid_method.

Value

An fs_path: the absolute path of the environment directory.

Details

Looks up which registered backend owns env_name, and creates the backend's data directory when needed. It creates no environment. When env_name has no directory yet, it does not start or install micromamba.

Examples

condathis::with_sandbox_dir({
  # Get the default environment directory
  print(condathis::get_env_dir())
  #> <data dir>/R/condathis/envs/condathis-env

  # Get the directory for a specific environment
  condathis::get_env_dir("my-env")
  #> <data dir>/R/condathis/envs/my-env
})
#> /tmp/Rtmpu60vo2/condathis-sandbox-2b123f875c5f/data/R/condathis/envs/condathis-env
#> /tmp/Rtmpu60vo2/condathis-sandbox-2b123f875c5f/data/R/condathis/envs/my-env