每晚安装最新的 Rust 抱怨缺少 rls 组件

Installing latest rust nightly complains about missing rls component

正在尝试编译:https://github.com/SergioBenitez/Rocket/tree/master/examples/hello

Cargo.toml

[dependencies]
rocket = "0.4.10"

抱怨我每晚都需要 rust

$ cargo build
...
  Error: Rocket (core) requires a more recent version of rustc.
  Installed version: 1.54.0 (2021-05-17)
  Minimum required:  1.54.0-nightly (2021-05-18)

我已经完成本地目录覆盖

$ rustup override set nightly

我 运行 每晚 2021-05-17 但我需要 2021-05-18

$ rustup show
...
active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (directory override for '/<redacted>')
rustc 1.54.0-nightly (3e99439f4 2021-05-17)

我尝试了各种命令来获取更新的每晚

$ rustup update
$ rustup update nightly
$ rustup toolchain install nightly-2021-05-18

我做的时候有一些奇怪的东西rustup update nightly

$ rustup update nightly 
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: latest update on 2021-05-23, rust version 1.54.0-nightly (e4ca1662f 2021-05-22)
info: skipping nightly which is missing installed component 'rls'
info: syncing channel updates for 'nightly-2021-05-22-x86_64-unknown-linux-gnu'
info: latest update on 2021-05-22, rust version 1.54.0-nightly (5dc8789e3 2021-05-21)
info: skipping nightly which is missing installed component 'rls'
info: syncing channel updates for 'nightly-2021-05-21-x86_64-unknown-linux-gnu'
info: latest update on 2021-05-21, rust version 1.54.0-nightly (40d230204 2021-05-20)
info: skipping nightly which is missing installed component 'rls'
info: syncing channel updates for 'nightly-2021-05-20-x86_64-unknown-linux-gnu'
info: latest update on 2021-05-20, rust version 1.54.0-nightly (f94942d84 2021-05-19)
info: skipping nightly which is missing installed component 'rls'
info: syncing channel updates for 'nightly-2021-05-19-x86_64-unknown-linux-gnu'
info: latest update on 2021-05-19, rust version 1.54.0-nightly (4e3e6db01 2021-05-18)
info: skipping nightly which is missing installed component 'rls'
info: syncing channel updates for 'nightly-2021-05-18-x86_64-unknown-linux-gnu'

  nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.54.0-nightly (3e99439f4 2021-05-17)

抱怨 skipping nightly which is missing installed component 'rls',我不知道如何解决这个问题

如有任何帮助,我们将不胜感激

抱歉,文字太长,如果您只想快速修复,请参阅下面的您的问题的解决方案。您也可以查看 the rustup book,它包含有关此类问题的信息。


您正在尝试安装 Rust 的夜间版本。在夜间版本中,Rust 的非必要组件的可用性,例如 Rust Language Server (or short rls) is not guaranteed – if they fail to build, the nightly is shipped without them. You can see here that rls indeed was not part of the last few nightlies. The last day a nightly was shipped with rls was 2021-05-18, which is a build from the day before, so 2021-05-17 (a bit irritating, but this seems to be accepted behavior).

您的 rustup 安装似乎配置为包括 rls。因此,当您告诉 rustup 更新您的 nightly 工具链时,rustup 会选择包含 rls 的最新夜间 。没有比您当前安装的 nightly-2021-05-17 更新的 nightlies,因此,rustup 不会更新工具链。

您的问题的解决方案

  • 如果您不需要 rls(只有在 IDE 和类似的东西中自动完成才需要),您的问题有多种解决方案:
    • 您可以从夜间工具链中删除 rls 组件:rustup component remove --toolchain nightly rls
    • The rustup book还有一些解决办法:

      If [a previously installed component] is missing, rustup will automatically search for an older release that contains the required components. There are several ways to change this behavior:

      • Use the --force flag to rustup toolchain install to force it to install the most recent version even if there is a missing component.
      • Use the --profile flag to rustup toolchain install to use a different profile that does not contain the missing component. For example, --profile=minimal should always work, as the minimal set is required to exist. See the Profiles chapter for more detail.
      • Install a specific date that contains the components you need. For example, rustup toolchain install nightly-2020-07-27. You can then use overrides to pin to that specific release.
  • 如果您确实需要 rls,您就有点为难了。您可能想要 use a override 用于您的项目,实际上使用不同的 Rust 构建来构建您的代码和 运行 rls。然而,这可能行不通——rls 可能需要为自动完成构建你的项目依赖项,而 Rocket 不允许使用较旧的 nightlies。对于这种情况,我真的没有解决方案——您可能需要继续使用旧版本的 Rocket 或暂时停止使用 rls,直到有更新的 Rust 每晚发布 rls