gpt4 book ai didi

rust - 错误 : toolchain 'stable-x86_64-apple-darwin' does not have the binary `rustfmt`

转载 作者:行者123 更新时间:2023-11-29 07:40:57 29 4
gpt4 key购买 nike

我运行了 rustup update 来更新我的工具链并看到了两个警告:

warning: tool `rustfmt` is already installed, remove it from `/Users/<username>/.cargo/bin`, then run `rustup update` to have rustup manage this tool.
warning: tool `cargo-fmt` is already installed, remove it from `/Users/<username>/.cargo/bin`, then run `rustup update` to have rustup manage this tool.

我按照警告消息中的说明进行操作,然后再次尝试运行 rustfmt。我得到了错误

error: toolchain 'stable-x86_64-apple-darwin' does not have the binary rustfmt`

出了什么问题,我该如何解决?

最佳答案

在您的系统中安装 rustfmt 的最标准和可靠的方法是确保在您的 Rustup 工具链中安装了 rustfmt 组件

rustup component add rustfmt

或者对于特定的工具链:

rustup component add rustfmt --toolchain nightly-2020-06-09

夜间工具链中的测试和构建有可能会失败,这意味着那些不太可能总是有这个组件。最新的 stablebeta 工具链通常会根据 No Tool Breakage Week 提供它。政策。

为了让 Rustup 管理 rustfmt,请看以下步骤:

  1. 将 Rustup 更新到最新版本后,您可能会收到消息警告:工具 rustfmt 已安装。按照建议从 Cargo 的二进制文件夹中删除二进制文件。 cargo uninstall rustfmt(如果安装了 rustfmt-nightly)效果很好。
  2. 运行 rustup update 让它用自己管理的 rustfmtcargo-fmt 填充已删除的二进制文件。
  3. 确保安装了您希望使用的工具链(例如stable)
  4. 运行上面的命令,确保为该工具链安装了 rustfmt 组件。

完成后,调用 rustfmt 将按预期工作:

$ rustup run stable rustfmt --version
rustfmt 1.4.12-stable (a828ffea 2020-03-11)

或者通过 Cargo 子命令:

$ cargo fmt --version
rustfmt 1.4.12-stable (a828ffea 2020-03-11)

在早期,由 Rustup 管理的 rustfmt 可能有点令人困惑,因为 Rustup 并不总是有 rustfmt,而且仍然经常作为预览出现必须以名称 rustfmt-preview 安装的组件。有一些关于该主题的相关问题和 PR(#1305#1310)。

关于rust - 错误 : toolchain 'stable-x86_64-apple-darwin' does not have the binary `rustfmt` ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47945066/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com