Checks whether an environment name is present in the environments managed
by condathis.
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
NULorCOM1(see Environment names increate_env()).
Invalid values abort with class
condathis_invalid_env_name.run(),run_bin(),run_pipeline()andrun_step()also accept anenv_path()value. The other functions reject it with classcondathis_env_path_read_only.- method
Character string naming the backend to query.
"auto"(the default) covers every registered backend, ingetOption("condathis.backend_priority")order, also a backend that reports itself unavailable. The name of a registered backend (seelist_registered_backend_names()) queries only that backend."micromamba"is built in. The name of a backend whose package condathis knows, such as"rattler"of therattlerthispackage, also queries only that backend. condathis loads that package. When it is not installed, the call aborts with classcondathis_backend_not_installed."native"is a deprecated alias for"micromamba"(warns once per session). Invalid values abort with classcondathis_invalid_method.- verbose
Character string that controls the console output. One of:
"output": show the output of the command and the messages ofcondathis."silent": show nothing."cmd": show the command line."spinner": show only a spinner."full": show the command line, the output, and the backend's own log.
TRUEmeans"output"andFALSEmeans"silent". Every level except"silent"shows a spinner in interactive sessions. It also shows these messages and this warning when they occur (see condathis-conditions):condathis_micromamba_downloading(a message): no usablemicromambawas found, so it is downloaded. Queries, such aslist_envs(), never download it.condathis_env_lock_waitingandcondathis_cache_lock_waiting(messages): the call waits for another R session.condathis_install_micromamba_checksum_unavailable(a warning): the checksum of the downloadedmicromambacould not be checked.
Invalid values abort with class
condathis_invalid_verbose. The default is shown in Usage.The command line shown, the
cmdof a result and the messages ofcondathisshow the password and the token of a URL as*****.micromambadoes the same (https://user:*****@host/channel,https://host/t/*****/channel). The command still gets them.
Value
TRUE when a queried backend reports the environment. FALSE
when every queried backend reports it absent. When the query fails for
the backend that method names, env_exists() aborts with class
condathis_env_exists_failed (also condathis_backend_error). With
method = "auto", a backend whose query fails is skipped, with a
warning of class condathis_backend_query_failed, and env_exists()
aborts only when every backend fails.
Details
env_exists() is a query: it never creates an environment. When
env_name has no directory under a backend's data directory, as on a new
data directory, env_exists() returns FALSE. It does not start or
install micromamba.
When no micromamba binary is installed, the micromamba backend reads
the envs directory of its data directory and the package records in
conda-meta/ instead. It never installs micromamba.
See also
condathis-conditions for every condition class.
Other environments:
create_env(),
env_definition(),
env_path(),
get_env_dir(),
install_packages(),
list_envs(),
list_packages(),
remove_env(),
validate_env()
Examples
condathis::with_sandbox_dir({
# A query: it creates nothing and needs no micromamba
condathis::env_exists("non-existent-env")
})
#> [1] FALSE
if (FALSE) { # \dontrun{
condathis::with_sandbox_dir({
# A local channel shipped with condathis, with `polyglot`: a
# dependency-free script that runs on Linux, macOS and Windows.
channel <- system.file(
"extdata", "polyglot-channel",
package = "condathis"
)
# Create the environment
condathis::create_env(
"polyglot",
env_name = "polyglot-env",
channels = channel
)
# Check if the environment exists
print(condathis::env_exists("polyglot-env"))
#> [1] TRUE
# Check for a non-existent environment
condathis::env_exists("non-existent-env")
#> [1] FALSE
})
} # }