LinuxCommandLibrary

cargo-binstall

Install pre-built Rust binaries

TLDR

Install a package from

$ cargo binstall [package]
copy

Install a specific version of a package (latest by default)
$ cargo binstall [package]@[version]
copy

Install a package and disable confirmation prompts
$ cargo binstall [[-y|--no-confirm]] [package]
copy

SYNOPSIS

cargo binstall [OPTIONS] <CRATE_NAMES>...

PARAMETERS

<CRATE_NAMES>...
    One or more names of the Rust crates (binaries) to install.

--install-dir <DIR>
    Specify the directory where the binaries should be installed (defaults to ~/.cargo/bin).

--bin-dir <DIR>
    Alias for --install-dir.

--force, -f
    Force installation, overwriting any existing binaries without prompting.

--no-confirm
    Do not prompt for confirmation; assume 'yes' to all questions.

--version <VERSION_CONSTRAINT>
    Specify a version constraint for the crate to install (e.g., 1.2.3, ^1.0).

--git <URL>
    Install from a specified Git repository URL.

--tag <TAG>
    When installing from Git, specify a release tag to use.

--path <PATH>
    Install from a local path, typically used for local development.

--force-compile
    Force compilation from source using cargo install, even if a pre-built binary is found.

--no-fallback
    Do not fall back to cargo install if binstall fails to find or install a pre-built binary.

--crates-io
    Always attempt to fetch assets directly from crates.io release metadata first.

--debug
    Enable debug logging for more verbose output during installation.

--quiet, -q
    Suppress most output, showing only errors.

--help
    Display a help message for cargo-binstall.

--version
    Display the version of cargo-binstall itself.

DESCRIPTION

cargo-binstall is a subcommand for Rust's package manager, Cargo, designed to accelerate the installation of Rust binaries. Unlike the standard cargo install, which compiles crates from source, cargo-binstall prioritizes downloading pre-built executables. It intelligently scans well-known locations, such as GitHub release assets or crates.io metadata, for binaries compatible with your system architecture.

If a pre-built binary is found, it's downloaded, verified (where possible), and installed directly into your ~/.cargo/bin directory, significantly reducing installation time by bypassing the compilation step. This is particularly beneficial for frequently used tools, CI/CD pipelines, or environments where compile times are a bottleneck. If cargo-binstall cannot locate a suitable pre-built binary, it gracefully falls back to using cargo install to compile and install the crate from source, ensuring that the desired tool is eventually installed, albeit potentially slower. It dramatically improves the user experience for installing many common Rust development tools.

CAVEATS

cargo-binstall's effectiveness largely depends on whether crate maintainers provide pre-built binaries for their projects. Not all Rust projects offer these, in which case it will fall back to slower compilation.

Downloading and executing binaries from external sources (like GitHub releases) carries inherent security risks. Users should always be mindful of the source and trust the maintainers of the software they install.

Pre-built binaries must also be compatible with your operating system and architecture; if none are found, compilation will be the only option.

INSTALLATION

To use cargo-binstall, you must first install it using the standard cargo install command:
cargo install binstall
This command compiles and installs cargo-binstall itself, making the cargo binstall subcommand available.

CONFIGURATION

cargo-binstall can be configured via your Cargo configuration file, typically located at ~/.cargo/config.toml. You can define default behaviors, such as always assuming 'yes' to prompts or setting preferred installation directories, under a [binstall] section. For example:
[binstall]
assume-yes = true

HISTORY

cargo-binstall emerged as a community-driven solution to a common pain point in the Rust ecosystem: the often slow compilation times associated with installing command-line tools via cargo install. It was designed to leverage the growing trend of Rust project maintainers providing pre-built binaries in their GitHub releases or similar platforms. First appearing around 2021, its development was motivated by a desire to provide a much faster, "npm-like" installation experience for common Rust tools, particularly beneficial for continuous integration (CI) environments and quick developer setups, making the Rust development workflow more efficient.

SEE ALSO

Copied to clipboard