Downloads the micromamba binary that condathis uses and installs it
in the condathis data directory, at the path that
micromamba_bin_path() returns. The functions that need micromamba call
it when no usable binary is found (see micromamba discovery in
condathis-options), for the default version. They first show a message
of class condathis_micromamba_downloading that names the version and
the path, unless their verbose is "silent". You need to call it only
to choose the version, or to install micromamba ahead of time.
Usage
install_micromamba(
micromamba_version = "2.10.0-0",
timeout = 3600,
download_method = "auto",
force = FALSE,
verbose = c("output", "silent", "cmd", "spinner", "full"),
timeout_limit = NULL
)Arguments
- micromamba_version
Character string with the micromamba version, in the format
"X.Y.Z-N"(version and build number), for example"2.10.0-0", the default.condathisdoes not use versions older than 2.8.1. Invalid values abort with these classes:condathis_install_micromamba_invalid_micromamba_version: another format.condathis_install_micromamba_unsupported_version: a version older than 2.8.1.
With
micromamba_version, an installed binary is kept only when its version (X.Y.Z) is the requested one. When it reports another version, or its version cannot be read,install_micromamba()installs the requested version. Withoutmicromamba_version, it always keeps an installed binary, unlessforce = TRUE.- timeout
Numeric download timeout in seconds, a single non-negative number.
Infmeans no limit. Defaults to3600. Each download uses the larger of this value andgetOption("timeout"), so0means no limit only whengetOption("timeout")is0too. The function lowers values above 2147483 seconds (about 24.8 days) to 2147483. Other values abort with classcondathis_install_micromamba_invalid_timeout.- download_method
Character string with the download method of
utils::download.file(): one of"auto"(the default),"internal","libcurl","wget","curl"or"wininet". It is ignored when thecurlpackage 5.0.0 or later is installed, because thencurl::curl_download()is used. Other values abort with classcondathis_install_micromamba_invalid_download_method.- force
Logical value.
TRUEdownloads micromamba also when a binary is already installed. Defaults toFALSE. A value that is notTRUEorFALSEaborts with classcondathis_install_micromamba_invalid_force.- verbose
Character string that controls the console output. One of
"output","silent","cmd","spinner"or"full"."output"and"full"show the progress of the download and the messages ofcondathis, for example thatmicromambais already installed, that the file of a mirror failed the checks, or that the download succeeded. The other levels show none of them. Every level except"silent"shows the warning of classcondathis_install_micromamba_checksum_unavailable(see Details and condathis-conditions).TRUEmeans"output"andFALSEmeans"silent". Invalid values abort with classcondathis_invalid_verbose. The default is shown in Usage.- timeout_limit
Deprecated. Use
timeout. A value warns with classcondathis_deprecated_argand is used astimeout. Passing both aborts with classcondathis_install_micromamba_conflicting_args.
Value
The path of the micromamba binary, an fs_path, invisibly: the
path that micromamba_bin_path() returns. A failed download aborts
with class condathis_install_micromamba_download_failed.
Details
The binary is the build for the platform of the running R (see
get_sys_arch()): linux-64, linux-aarch64, linux-ppc64le,
linux-riscv64, osx-64, osx-arm64, win-64 or win-arm64. On
another platform, install_micromamba() aborts with class
condathis_micromamba_not_available_for_arch.
linux-riscv64 has builds from micromamba 2.9.0 on, so an older
version aborts there with the same class. The GitHub releases have them
from 2.10.0-0 on: 2.9.0 comes from the conda-forge mirrors, and its
checksum cannot be checked (see below).
A native ARM64 R on Windows gets win-arm64. An x64 R on an ARM64 PC
gets win-64, which runs through x64 emulation. Every R of a user
shares the installed binary. So on an ARM64 PC, the binary installed
first stays until you replace it, for example with force = TRUE.
Either binary works with both builds of R: micromamba builds
environments for its own platform.
install_micromamba() tries the compressed archive first, from the
micromamba releases on GitHub, then from the conda-forge channel on
anaconda.org and prefix.dev. It extracts the archive with R's internal
tar, so no system tar or bzip2 is needed. When every archive
fails, it downloads the standalone binary from GitHub. A mirror fails
when the download fails, or when the file does not extract, does not
run, or does not match the SHA256 checksum published with the release.
Then it tries the next mirror. It replaces an installed binary only with
a download that passed these checks, also with force = TRUE.
The checksum is downloaded from the GitHub release when the binary is
installed. When it cannot be downloaded or read, or the SHA256 hash of
the binary cannot be computed, install_micromamba() still installs the
binary, so that mirrors work when GitHub cannot be reached, but warns
with class condathis_install_micromamba_checksum_unavailable. It warns
for every verbose level except "silent", also when a function that
needs micromamba installs it. A checksum that does not match warns with
class condathis_install_micromamba_checksum_mismatch, also when
verbose is "silent", and that binary is not installed. The hash is
computed with tools::sha256sum() on R 4.5.0 or later, else with the
digest package when it is installed, else with the sha256sum or
shasum program, or on Windows certutil.
See also
Other setup:
clean_cache(),
get_install_dir(),
get_sys_arch(),
micromamba_bin_path(),
with_sandbox_dir()
Examples
if (FALSE) { # \dontrun{
condathis::with_sandbox_dir({
# Install the default version of micromamba
condathis::install_micromamba()
# Install a specific version (2.8.1 or newer): it replaces a binary of
# another version
condathis::install_micromamba(micromamba_version = "2.9.0-0")
# Without `micromamba_version`, the installed binary is kept unless
# `force = TRUE`
condathis::install_micromamba(force = TRUE)
})
} # }