首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:工具链“稳定-x86_64-苹果-达尔文”没有二进制的“`rustfmt`”

错误:工具链“稳定-x86_64-苹果-达尔文”没有二进制的“`rustfmt`”
EN

Stack Overflow用户
提问于 2017-12-22 17:11:54
回答 3查看 8.2K关注 0票数 28

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

代码语言:javascript
复制
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。我得到了错误

代码语言:javascript
复制
error: toolchain 'stable-x86_64-apple-darwin' does not have the binary rustfmt`

哪里出了问题,我怎么解决呢?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-12-22 17:33:51

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

代码语言:javascript
复制
rustup component add rustfmt

或者对于特定的工具链:

代码语言:javascript
复制
rustup component add rustfmt --toolchain nightly-2020-06-09

在夜间工具链中的测试和构建有可能失败,这意味着这些测试和构建不太可能总是具有此组件。最新的stablebeta工具链通常会按照无工具破损周策略使用。

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

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

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

代码语言:javascript
复制
$ rustup run stable rustfmt --version
rustfmt 1.4.12-stable (a828ffea 2020-03-11)

或通过货物分命令:

代码语言:javascript
复制
$ cargo fmt --version
rustfmt 1.4.12-stable (a828ffea 2020-03-11)

在早期,由Rustup管理的rustfmt可能会有些混乱,因为Rustup并不总是有rustfmt,而且仍然会经常出现预览组件,必须以rustfmt-preview的名称安装。在这个主题上有一些相关的问题和PRs (#1305#1310)。

票数 22
EN

Stack Overflow用户

发布于 2018-05-15 13:59:59

该错误告诉您,您没有在实际的rustfmt-preview上安装*-apple-darwin

你需要做的是:

rustup component add rustfmt-preview --toolchain stable-x86_64-apple-darwin

在你准备好之后:)

票数 18
EN

Stack Overflow用户

发布于 2018-10-29 03:34:07

代码语言:javascript
复制
$ rustup run stable rustfmt --version
error: `toolchain 'stable-x86_64-pc-windows-msvc' does not have th`e binary `rustfmt.exe`

$ rustup component remove rustfmt-preview --toolchain=stable-x86_64-pc-windows-msvc
info: removing component 'rustfmt-preview'
warning: during uninstall component rustfmt-preview-x86_64-pc-windows-msvc was not found

$ rustup component add rustfmt-preview --toolchain=stable-x86_64-pc-windows-msvc
info: downloading component 'rustfmt-preview'
info: installing component 'rustfmt-preview'

$ rustup run stable rustfmt --version
rustfmt 0.99.1-stable (da17b689 2018-08-04)

https://users.rust-lang.org/t/problem-with-rustfmt-on-stable/15165/7

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47945066

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档