75 个版本 (38 个稳定版)

1.10.2 2024年8月13日
1.8.0 2024年7月26日
1.6.4 2024年3月9日
1.4.9 2023年12月26日
0.2.0 2020年12月31日

#16 in Cargo 插件

Download history 37650/week @ 2024-05-02 32383/week @ 2024-05-09 34872/week @ 2024-05-16 35021/week @ 2024-05-23 33874/week @ 2024-05-30 40180/week @ 2024-06-06 46301/week @ 2024-06-13 39982/week @ 2024-06-20 36274/week @ 2024-06-27 34307/week @ 2024-07-04 41323/week @ 2024-07-11 41196/week @ 2024-07-18 49083/week @ 2024-07-25 50183/week @ 2024-08-01 53578/week @ 2024-08-08 42628/week @ 2024-08-15

每月下载量 202,891

GPL-3.0-only

180KB
4K SLoC

Cargo B(inary)Install

Binstall 提供了一种低复杂度的机制,用于将 Rust 二进制文件安装为源码构建(通过 cargo install)或手动下载包的替代方案。这旨在与现有的 CI 艺术品和基础设施一起工作,并为包维护者提供最小的开销。

Binstall 通过从 crates.io 获取包信息,并在链接的 repository 中搜索匹配的发布和艺术品,回退到第三方艺术品托管 quickinstall,然后是支持的目标,最后是作为最后的手段的 cargo install

CI build GitHub tag Crates.io

您可能想查看 最新版本发布时的页面

用法

$ cargo binstall [email protected]
 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

Binstall 在许多情况下旨在作为 cargo install 的替代方案,并支持类似选项。

对于无人值守的使用(例如,在 CI 中),请使用 --no-confirm 标志。有关其他选项,请参阅 cargo binstall --help

安装

如果您已经有了它

要升级 cargo-binstall,请使用 cargo binstall cargo-binstall

快速

以下是一行命令,用于下载和安装预编译的 cargo-binstall 二进制文件。

Linux 和 macOS

curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash

或者如果你已经安装了 homebrew

brew install cargo-binstall

Windows

Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content

手动

下载适合你系统的相关包,解压它,然后将 cargo-binstall 可执行文件移动到 $HOME/.cargo/bin

操作系统 Arch URL
Linux x86_64 https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
Linux armv7 https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-armv7-unknown-linux-musleabihf.tgz
Linux arm64 https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-aarch64-unknown-linux-musl.tgz
Mac Intel https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-apple-darwin.zip
Mac Apple Silicon https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-aarch64-apple-darwin.zip
Mac 通用
(两种架构)
https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-universal-apple-darwin.zip
Windows Intel/AMD https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-pc-windows-msvc.zip
Windows ARM 64 https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-aarch64-pc-windows-msvc.zip

从源码

安装了最新的 Rust

cargo install cargo-binstall

在 GitHub Actions 中

我们提供了一个第一方的最小化操作,用于安装 Binstall 的最新版本

  - uses: cargo-bins/cargo-binstall@main

对于更多功能,我们推荐出色的 taiki-e/install-action,它为选定的工具提供专用支持,并使用 Binstall 安装其他所有内容。

配套工具

这些是与 Binstall 一起很好地工作的有用 第三方 工具。

cargo-update

虽然你可以通过再次运行 cargo binstall 显式地升级包,但 cargo-update 会负责根据需要更新所有工具。如果存在,它将自动使用 Binstall 安装更新。

cargo-run-bin

Binstall 和 cargo install 都默认全局安装工具,这对于系统工具来说很好。但是,当你为项目安装工具时,你可能更喜欢将工具范围限定在该项目内,并在代码中控制它们的版本。这就是 cargo-run-bin 的作用,它在 Cargo.toml 中有一个专用部分,并有一个简短的 cargo 子命令。当 Binstall 可用且可能时,它会从二进制文件安装...你甚至可以用 cargo-run-bin 管理Binstall本身!

不支持的包

Binstall 通常足够智能,可以在大多数情况下自动检测工件。但是,如果某个包安装失败,你可以在命令行中手动指定所需的 pkg-urlbin-dirpkg-fmt,这些值如 SUPPORT.md 中所述。

$ cargo-binstall \
  --pkg-url="{ repo }/releases/download/{ version }/{ name }-{ version }-{ target }.{ archive-format }" \
  --pkg-fmt="txz" \
  crate_name

维护者想要让用户的生活更轻松,可以向 Cargo.toml 中添加 显式的 Binstall 元数据,以定位特定版本和目标的适当二进制包。

签名

我们为维护者提供了初始的、有限的 支持,以指定签名公钥和查找包签名的地方。启用此功能后,Binstall 将下载并验证该包的签名。

你可以使用 --only-signed 来拒绝安装未签名的包。

如果你喜欢冒险(请勿在测试之外使用),你可以使用 --skip-signatures 来禁用检查甚至完全不下载签名。

常见问题解答

为什么使用这个工具?

因为使用 wget 下载发布版本很令人沮丧,cargo install 在设备受限的情况下需要花费相当长的时间,而且通常将实际的 软件包 组合在一起是过度的。

为什么使用 cargo 清单?

软件包已经包含了这些,并且它们已经包含了所需信息的很大一部分。此外,还有一个非常好的、但使用不足的(据我所知)[package.metadata] 字段。

这是安全的吗?

是的,但也不是完全的?

我们提供了对签名验证的初始支持,但目前生态系统产生签名的并不多。参见 #1 来讨论更多关于这一点的内容。

我们始终通过 HTTPS 从 crates.io 拉取元数据,并验证软件包 tar 的校验和。我们还将使用 HTTPS 与 TLS >= 1.2 强制执行实际下载包文件的协议。

与像 curl ... | sh 这样的脚本相比,我们不会运行任意代码,但当然,你下载的软件包本身可能是有害的!

错误代码的含义是什么?

您可以在这里找到错误(包括退出代码)的完整描述。

调试符号可用吗?

是的!带有 .full 后缀的额外预构建软件包包含拆分的调试信息、文档文件以及如 detect-wasi 实用程序之类的额外二进制文件。


如果您有任何想法/贡献或者有任何事情没有按预期工作(在这种情况下,请包括使用 --log-level debug 的输出),请随时打开问题或 PR。

依赖关系

~24–63MB
~1M SLoC