cargo-binstall: Streamlining Binary Installation for Rust Projects

Summary
cargo-binstall offers an efficient and low-complexity method for installing Rust binaries, serving as a robust alternative to building from source or manual downloads. It integrates seamlessly with existing CI artifacts and infrastructure, minimizing overhead for package maintainers. By leveraging crates.io and repository releases, cargo-binstall simplifies the process of getting Rust tools up and running.
Repository Info
Tags
Click on any tag to explore related repositories
Introduction
cargo-binstall is a powerful tool designed to simplify the installation of Rust binaries. It provides a low-complexity mechanism for quickly getting Rust projects installed, acting as an an alternative to the often time-consuming cargo install (which builds from source) or the manual process of downloading packages. cargo-binstall works by fetching crate information from crates.io and then searching the linked GitHub repository for matching releases and pre-compiled artifacts. This approach significantly speeds up the setup process for developers and CI/CD pipelines.
Installation
Getting cargo-binstall up and running is straightforward.
Quickly
For Linux and macOS users, you can install it with a single curl command:
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
Alternatively, if you use Homebrew, install it with:
brew install cargo-binstall
For Windows, use PowerShell:
Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content
From Source
If you prefer to install from source, ensure you have a recent Rust installation and run:
cargo install cargo-binstall
Upgrading
To upgrade cargo-binstall itself, simply run:
cargo binstall cargo-binstall
Examples
Using cargo-binstall is similar to cargo install. Here's an example of installing a specific version of a crate:
$ cargo binstall radio-sx128x@0.14.1-alpha.5
INFO resolve: Resolving package: 'radio-sx128x@=0.14.1-alpha.5'
WARN The package radio-sx128x v0.14.1-alpha.5 (x86_64-unknown-linux-gnu) has been downloaded from github.com
INFO This will install the following binaries:
INFO - sx128x-util (sx128x-util-x86_64-unknown-linux-gnu -> /home/.cargo/bin/sx128x-util)
Do you wish to continue? [yes]/no
? yes
INFO Installing binaries...
INFO Done in 2.838798298s
For unattended use, such as in CI environments, you can use the --no-confirm flag.
Why use this?
cargo-binstall addresses several common frustrations in the Rust ecosystem. Manually downloading releases can be tedious, and cargo install often takes a significant amount of time, especially on resource-constrained devices, due to compiling from source. While creating full packages might be overkill for many scenarios, cargo-binstall provides a perfect middle ground, offering quick binary installations without the overhead of full package management or lengthy compilation times.
Links
- GitHub Repository: https://github.com/cargo-bins/cargo-binstall
- Crates.io: https://crates.io/crates/cargo-binstall
- Documentation (Error Codes): https://docs.rs/binstalk/latest/binstalk/errors/enum.BinstallError.html
- Support Documentation: https://github.com/cargo-bins/cargo-binstall/blob/main/SUPPORT.md