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. run(), run_bin(), run_pipeline() and run_step() also accept an env_path() value. The other functions reject it with class condathis_env_path_read_only.

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. "native" is a deprecated alias for "micromamba" (warns once per session). The 0.1.4 default c("native", "auto") is read as "native".

If you name a backend other than the owner, functions that change the environment abort. The others warn and use the owner. The classes:

  • condathis_backend_not_installed: the package of the named backend is not installed.

  • condathis_backend_mismatch: the named backend does not own the environment, and the function changes it.

  • condathis_backend_mismatch_warning (a warning): the same, for a function that does not change the environment.

  • condathis_backend_ambiguous_env: several backends have an environment of that name, and method names none of them.

  • condathis_invalid_method: an invalid value.

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/Rtmpel16Et/condathis-sandbox-29a62d1581a8/data/R/condathis/envs/condathis-env
#> /tmp/Rtmpel16Et/condathis-sandbox-29a62d1581a8/data/R/condathis/envs/my-env