Every error that condathis raises has the class condathis_error, and
every warning has the class condathis_warning. Each condition also has
more specific classes. Use them to handle one kind of problem with
base::tryCatch(), base::withCallingHandlers() or
rlang::try_fetch(), and to test for it with
testthat::expect_error(class = ). Do not match the text of a message:
it can change in any release.
The class scheme
The classes of a condition go from the most specific to the most general:
The class of the function and the problem,
condathis_<function>_<problem>, with the full name of the exported function. For example:condathis_create_env_existscondathis_run_bin_env_not_found
Older names of that class, kept so that existing handlers still work (see Renamed classes). Some classes carry further names that this page does not list: do not rely on them.
Shared classes for the kind of problem. For example:
condathis_invalid_overwriteandcondathis_invalid_argcondathis_env_not_found
The root class,
condathis_errororcondathis_warning.
The rlang package adds its own classes after these, such as
rlang_error, error and condition.
For example, create_env(overwrite = "yes") aborts with these classes:
c(
"condathis_create_env_invalid_overwrite",
"condathis_create_invalid_overwrite_arg",
"condathis_invalid_overwrite",
"condathis_invalid_arg",
"condathis_error"
)The checks of verbose, method and error are the same in every
function, so their errors have only shared classes, for example:
Handle the most general class that fits. A handler for
condathis_env_not_found catches a missing environment in every
function, and a handler for condathis_error catches every error of
condathis.
Shared classes
condathis_invalid_arg
An argument has an invalid value.condathischecks the arguments before it changes anything, so such an error has no side effects.condathis_invalid_<argument>
An invalid value of one argument, with its exact name. It always comes with the classcondathis_invalid_arg. For example:condathis_invalid_env_namecondathis_invalid_packagescondathis_invalid_channelscondathis_invalid_methodcondathis_invalid_verbosecondathis_invalid_errorcondathis_invalid_timeout
condathis_parse_match_spec_invalid_namecondathis_parse_match_spec_invalid_url
A package spec that condathis cannot read, such as"::", or the URL of a package file whose name is not<name>-<version>-<build>.condathisreads the specs when it compares them with an existing environment, increate_env(),install_packages()andvalidate_env(). Alsocondathis_invalid_arg.condathis_env_not_found
The environment does not exist. A missing environment is created only byrun(),run_bin(),run_pipeline()andinstall_packages(), and only the default"condathis-env". Witherror = "continue", the run family returns status 127 instead. When the environment is in the data directory of a backend whose package cannot be used, the message names that backend (see the classcondathis_backend_not_installedbelow).condathis_backend_error
A backend failed. The function classes are:condathis_<function>_failedcondathis_<function>_resolve_failed
a command or its activation could not be resolved.condathis_backend_probe_failed
The backend's error is the parent, so its classes are found by
rlang::cnd_inherits(). Thecondathis_*classes of the backend's error are also copied, for example:condathis_micromamba_status_error
condathis_backend_probe_failed
A backend could not tell whether the environment exists.create_env(),install_packages()andremove_env()then stop before they change anything. Alsocondathis_backend_error.condathis_backend_query_failed(a warning)
Withmethod = "auto", a query of one backend failed, and the function skipped that backend.condathis_backend_invalid_return
A backend returned a value that breaks the contract ofregister_backend(). The message names the backend. Also:condathis_backend_contract_violation
For the value of
backend_resolve_run(), the first class is:condathis_backend_resolve_run_invalid
condathis_backend_contract_violation
A backend breaks the contract, when it is registered or in a return value.condathis_backend_not_installed
The package of a backend that condathis knows, such as"rattler"of therattlerthispackage, is not installed. It is:an error when
methodnames that backend (with the classes of an invalidmethod).an error when a call would change an environment in the data directory of that backend (with
condathis_backend_mismatch).a warning when a query skips the environments of that backend (once per session).
a warning when
clean_cache()cannot clean its caches.
condathis_backend_load_failed
The same, when the package is installed but failed to load, did not register its backend, or its backend was unregistered in this session. The error of the load is the parent. Also a warning, once per session, whencondathistried to load the package. It tries this when its backend has environments or caches, or when the optioncondathis.backend_prioritynames it.condathis_link_scripts_skipped(a warning)
The backend did not run the pre-link, post-link or pre-unlink scripts of some packages, which micromamba runs, so these packages may not work. The call itself succeeded. The warning has the fieldsbackend,env_name,packages(the package names, sorted) andscripts(a data frame with the columnspackageandscript).condathis_backend_quiesce_failed(a warning)with_sandbox_dir()orclean_cache()could not tell whether a backend still works in the R process, and went on.condathis_env_lock_waiting(a message, neither an error nor a warning)create_env(),install_packages()orremove_env()waits for another R session that changes the same environment (see Other R sessions increate_env()).condathis_cache_lock_waiting(a message)clean_cache()waits for other R sessions that create environments or install packages, or these wait for aclean_cache()of another session.condathis_micromamba_downloading(a message)
A function that needsmicromambafound no usable binary and downloads the default version withinstall_micromamba(). The message names the version and the path.verbose = "silent"hides it.condathis_env_lock_unavailable(a warning, once per session)
The lock of the environment or of the package caches could not be taken, for example on a file system that cannot lock files. The call went on without it.condathis_status_error
A command ofrun(),run_bin()orrun_pipeline()exited with a status other than 0.condathis_timeout_error
A command ofrun(),run_bin()orrun_pipeline()ran longer thantimeoutand was killed.condathis_micromamba_status_error
Amicromambacommand that condathis started for the micromamba backend failed. It carries the fieldsstatusandstderr, also when it is the class of a backend failure that condathis re-raised.Deprecated arguments and values, which still work but will be removed (warnings):
condathis_deprecated_packages_arg
forpackages =increate_env(),install_packages()andvalidate_env(): once per session and function, for calls from the console, a script or the tests of the calling package. Calls made inside other packages do not warn.options(lifecycle_verbosity = "warning")makes those calls warn too, and"quiet"turns the warning off. testthat's third edition setslifecycle_verbosity = "warning"insidetest_that(), so in those tests calls made inside other packages, such as a dependency that calls condathis, warn too;withr::local_options(lifecycle_verbosity = "quiet")silences them.condathis_deprecated_env_file_arg
forenv_file =increate_env(): pass anenv_definition()in...instead. The same rule as forpackages =.condathis_deprecated_method_native
formethod = "native"(once per session), in every function that takesmethod. The same rule as forpackages =.condathis_deprecated_arg
fortimeout_limitininstall_micromamba().
Error fields
The status and timeout errors of run(), run_bin() and
run_pipeline() carry these fields, so a handler does not need to read
the message:
status: the exit status, an integer. It is-9for a timeout, and127for a command that could not start. On Linux and macOS, a command killed by signalnhas the status128 + n, as in a shell (137forSIGKILL,141forSIGPIPE).stdout,stderr: the captured output, orNAwhen that stream was not captured.timeout:TRUEfor a timeout,FALSEotherwise.
The errors of run_pipeline() also carry result, the
condathis_pipeline result, and statuses, the status of each command.
Classes of each function
Each function also raises the shared classes above. The checks of
verbose, method and error raise only shared classes.
create_env()
The classes of create_env(). Arguments:
condathis_create_env_invalid_packagescondathis_create_env_positional_env_namecondathis_create_env_invalid_env_namecondathis_create_env_invalid_channelscondathis_create_env_invalid_channel_prioritycondathis_create_env_invalid_platformcondathis_create_env_invalid_env_file
an invalid value of the deprecatedenv_file.condathis_create_env_missing_env_file
the file of anenv_definition()or ofenv_filedoes not exist.condathis_create_env_invalid_overwritecondathis_create_env_conflicting_args
package specs and anenv_definition(), two definitions, a definition andenv_file, orchannels,additional_channelsorchannel_prioritywith a lock file given byenv_definition(). The deprecatedenv_fileignores them, as in 0.1.4.condathis_create_env_unsupported_definition
the backend cannot read theenv_definition(), or no available backend can withmethod = "auto". Alsocondathis_backend_unsupported.
The environment:
condathis_create_env_exists
it exists, andoverwrite = FALSEcannot keep it. A lock file keeps it only when the environment has exactly the packages of the lock.condathis_create_env_platform_mismatchcondathis_create_env_platform_not_locked
a lock file lists none of the platforms thatcreate_env()can use. Alsocondathis_create_env_platform_mismatch.
The backend:
condathis_create_env_failed
also when a lock file that lists packages gives an empty environment.condathis_create_env_link_scripts_skipped(a warning)
install_packages()
The classes of install_packages(). Arguments:
condathis_install_packages_missing_packagescondathis_install_packages_invalid_packagescondathis_install_packages_positional_env_namecondathis_install_packages_invalid_env_namecondathis_install_packages_invalid_channelscondathis_install_packages_invalid_channel_prioritycondathis_install_packages_conflicting_args
package specs and anenv_definition(), or two definitions.condathis_install_packages_missing_env_file
the file of anenv_definition()does not exist.condathis_install_packages_unsupported_definition
a lock file, or a file that the backend cannot read or install from (then alsocondathis_backend_unsupported).
The environment:
condathis_install_packages_env_not_found
The backend:
condathis_install_packages_failedcondathis_install_packages_link_scripts_skipped(a warning)condathis_install_packages_missing_previous_channels(a warning)
a channel the environment was built from is not in the call. This holds on every backend that records the channels inconda-meta/history.
remove_env()
The classes of remove_env():
condathis_remove_env_invalid_env_namecondathis_remove_env_env_not_foundcondathis_remove_env_failedcondathis_remove_env_link_scripts_skipped(a warning)
pre-unlink scripts.
clean_cache()
The classes of clean_cache():
condathis_clean_cache_failed
a backend failed to clean its caches, orcondathiscould not empty one of its own cache directories.condathisraises it after it cleaned the other backends and directories.A backend failure also has
condathis_backend_error, with the error of the backend as the parent. For a non-zerostatusthat the backend returned without an error, it has the fieldsstatus,stdoutandstderrinstead.A directory failure has the error of the deletion as the parent.
condathis_backend_invalid_return
a backend returned astatusthat is not a whole number.condathis_backend_not_installedandcondathis_backend_load_failed(warnings)
name a backend whose caches were not cleaned.
validate_env()
The classes of validate_env(). Arguments:
condathis_validate_env_invalid_packagescondathis_validate_env_positional_env_namecondathis_validate_env_invalid_env_namecondathis_validate_env_invalid_channelscondathis_validate_env_invalid_platformcondathis_validate_env_conflicting_args
package specs and anenv_definition(), or two definitions.condathis_validate_env_missing_env_file
the file of anenv_definition()does not exist.condathis_validate_env_unsupported_definition
a file that cannot be compared: a request such asenvironment.yml, a lock whose packages the backend does not report, or a lock without packages forplatform. Alsocondathis_backend_unsupportedwhen the backend cannot read the file.
The environment:
condathis_validate_env_env_not_foundcondathis_validate_env_unsatisfied
a spec is not satisfied, or the environment does not have exactly the packages of a lock file.
The backend:
condathis_validate_env_failed
Queries
These are the classes of the queries, with the name of the function as
<function>. The queries are env_exists(), list_envs(),
list_packages(), get_env_dir() and get_install_dir().
condathis_<function>_invalid_env_name
for the functions that takeenv_name.condathis_list_packages_env_not_foundcondathis_<function>_failed
not forget_env_dir().
install_micromamba()
The classes of install_micromamba(). Arguments:
condathis_install_micromamba_invalid_micromamba_versioncondathis_install_micromamba_invalid_timeoutcondathis_install_micromamba_invalid_download_methodcondathis_install_micromamba_invalid_forcecondathis_install_micromamba_conflicting_argstimeoutandtimeout_limit.
Then:
condathis_install_micromamba_unsupported_versioncondathis_install_micromamba_download_failed
The warnings about the SHA256 check of a download:
condathis_install_micromamba_checksum_unavailable
the binary is installed without the check.verbose = "silent"hides it.condathis_install_micromamba_checksum_mismatch
the binary is not installed. Shown also withverbose = "silent".
The micromamba backend
condathis_micromamba_downloading(a message)
no usable binary was found, so it is downloaded.condathis_micromamba_status_error
amicromambacommand failed.condathis_micromamba_env_file_dir_not_writable
the directory of an environment file with apip:section is not writable, so micromamba cannot write its temporary file there, and the section names paths relative to that directory, socondathiscannot pass a copy.create_env()andinstall_packages()raise it with their class of a backend failure.condathis_micromamba_bin_path_not_executablecondathis_micromamba_version_not_detectedcondathis_micromamba_not_available_for_arch
Replacing an environment
For create_env() with overwrite = TRUE, on every backend, three
classes apply:
condathis_env_set_aside_failed
the existing environment could not be moved aside, so it is unchanged.condathis_env_not_restored
the create failed and the old environment could not be moved back. The error has the fieldkept_env_dirwith where it is kept.condathis_env_restore_failed(a warning)
the same after an interrupt, also withkept_env_dir.
The micromamba backend adds:
condathis_micromamba_env_set_aside_failedcondathis_micromamba_env_restore_failed
When condathis replaces, removes or cleans up an environment, it
refuses to delete or move a directory that is not exactly
<root>/envs/<env_name>. The error has one of these classes:
condathis_unsafe_env_dir_deletecondathis_unsafe_env_dir_move
run() and run_bin()
The classes of run() and run_bin(), with run or run_bin as
<function>. Arguments:
condathis_<function>_invalid_cmdcondathis_<function>_invalid_args
a value in..., alsocondathis_invalid_cmd_args.condathis_<function>_invalid_inputcondathis_<function>_invalid_binarycondathis_<function>_invalid_env_namecondathis_<function>_invalid_<argument>
fortimeout,supervise,cleanup_tree,linux_pdeathsig,stdin,stdout,stderrandactivate.
Then:
condathis_<function>_env_not_foundcondathis_<function>_resolve_failedcondathis_<function>_status_errorcondathis_<function>_timeout_error
A failed activation of the micromamba backend adds the classes of its error to the resolve error:
On Linux and macOS, an
activate.dscript that exits with a non-zero status adds two classes:condathis_micromamba_status_errorcondathis_cmd_status_error
A missing or unreadable activation result adds
condathis_activation_dump_error.A missing environment directory adds
condathis_activation_env_not_found.
run_pipeline()
The classes of run_pipeline(). Arguments:
condathis_run_pipeline_invalid_stepcondathis_run_pipeline_too_few_commandscondathis_run_pipeline_conflicting_methodcondathis_run_pipeline_invalid_env_namecondathis_run_pipeline_invalid_inputcondathis_run_pipeline_invalid_binarycondathis_run_pipeline_invalid_<argument>
fortimeout,supervise,cleanup_tree,linux_pdeathsig,activate,stdin,stdoutandstderr.
Then:
condathis_run_pipeline_env_not_foundcondathis_run_pipeline_resolve_failedcondathis_run_pipeline_status_errorcondathis_run_pipeline_timeout_error
run_step()
The classes of run_step():
condathis_run_step_invalid_cmdcondathis_run_step_invalid_argscondathis_run_step_invalid_env_namecondathis_run_step_invalid_methodcondathis_run_step_invalid_stderr
env_path()
The classes of env_path():
condathis_env_path_invalid_path
thepathargument.condathis_env_path_invalid
a malformedenv_path()object. It is also the second class of apatherror.condathis_env_path_read_only
passed to a function that takes only names.condathis_env_path_unsupported_method
amethodthat names a backend that cannot run commands in such an environment, alsocondathis_backend_unsupported.condathis_env_path_not_foundcondathis_env_path_not_conda_env
alsocondathis_env_not_found.
env_definition()
The classes of env_definition():
condathis_env_definition_invalid_path
thepathargument, also a URL. Alsocondathis_invalid_path.condathis_env_definition_invalid_formatcondathis_env_definition_invalid_options
an unnamed or repeated option in....condathis_env_definition_invalid
a malformedenv_definition()object, found by the function that gets it.
A definition passed to a function that takes only package specs or names aborts with the class of the invalid argument of that function.
parse_output()
The classes of parse_output():
condathis_parse_output_invalid_rescondathis_parse_output_invalid_streamcondathis_parse_output_invalid_trimcondathis_parse_output_binary_stream
a raw stream cannot be parsed as text.
with_sandbox_dir()
The classes of with_sandbox_dir():
condathis_with_sandbox_dir_cleanup_failed(a warning)
the sandbox could not be deleted.
Backend selection (method)
The classes of the choice of a backend with method:
condathis_backend_not_registeredcondathis_backend_none_availablecondathis_backend_mismatch
a change to an environment of another backend.condathis_backend_ambiguous_env
several backends have the environment.condathis_backend_not_installedcondathis_backend_load_failed
the package of the backend cannot be used.
The warnings:
condathis_backend_mismatch_warningcondathis_backend_marker_mismatchcondathis_invalid_backend_priority_option
register_backend() and unregister_backend()
The classes of register_backend() and unregister_backend():
condathis_backend_invalid_namecondathis_backend_reserved_namecondathis_backend_root_conflict
the condathis data directory has an entry of that name that is not a directory.condathis_backend_name_conflict
the name differs only in case from another backend name.condathis_backend_class_conflictcondathis_backend_contract_violation
A backend gives its own condition the class
condathis_backend_unsupported when it cannot honor an argument, and
never the class condathis_backend_error.
Renamed classes
These classes of condathis 0.1.4 were renamed to follow the scheme.
Each old name is kept as an extra class until condathis 1.0, so
existing handlers keep working. Use the new names in new code. Each item
gives the new class, then the old one:
condathis_create_env_invalid_overwrite
old:condathis_create_invalid_overwrite_argcondathis_create_env_missing_env_file
old:condathis_create_missing_env_filecondathis_remove_env_env_not_found
old:condathis_error_env_removecondathis_list_packages_env_not_found
old:condathis_list_packages_missing_envcondathis_install_micromamba_download_failed
old:condathis_install_error_missing_bzip2condathis_micromamba_bin_path_not_executable
old:condathis_umamba_bin_path_not_executablecondathis_micromamba_version_not_detected
old:condathis_umamba_version_not_detectedcondathis_micromamba_not_available_for_arch
old:condathis_umamba_not_available_for_archcondathis_micromamba_status_error
old:condathis_cmd_status_errorcondathis_run_invalid_cmd
old:condathis_run_null_cmdcondathis_run_invalid_stdincondathis_run_bin_invalid_stdin
old:condathis_run_stdin_errorcondathis_run_bin_status_error
old:condathis_run_status_errorcondathis_run_invalid_argscondathis_run_bin_invalid_args
(a named value) old:rlib_error_dots_named,rlib_error_dots
condathis_install_error_missing_bzip2 is deprecated: a failed download
does not depend on bzip2.
Examples
condathis::with_sandbox_dir({
# A missing environment, in any function
print(tryCatch(
condathis::list_packages(env_name = "no-such-env"),
condathis_env_not_found = function(cnd) "not found"
))
# An invalid argument aborts before anything runs
print(tryCatch(
condathis::create_env(env_name = "my-env", overwrite = "yes"),
condathis_invalid_arg = function(cnd) class(cnd)
))
})
#> [1] "not found"
#> [1] "condathis_create_env_invalid_overwrite"
#> [2] "condathis_create_invalid_overwrite_arg"
#> [3] "condathis_invalid_overwrite"
#> [4] "condathis_invalid_arg"
#> [5] "condathis_error"
#> [6] "rlang_error"
#> [7] "error"
#> [8] "condition"
if (FALSE) { # \dontrun{
condathis::with_sandbox_dir({
# The fields of a status error. The command is the Rscript of this R,
# run in the default environment, which is created empty.
rscript <- file.path(
R.home("bin"),
if (.Platform$OS.type == "windows") "Rscript.exe" else "Rscript"
)
tryCatch(
condathis::run(rscript, "-e", "quit(status = 3)", verbose = "silent"),
condathis_status_error = function(cnd) cnd$status
)
})
} # }