我有类似的问题。
$ cat rust-toolchain.toml
[toolchain]
channel = "nightly"
$ rustup show
Default host: aarch64-apple-darwin
rustup home: /Users/n8henrie/.rustup
installed toolchains
--------------------
stable-aarch64-apple-darwin (default)
nightly-aarch64-apple-darwin
active toolchain
----------------
stable-aarch64-apple-darwin (default)
rustc 1.50.0 (cb75ad5db 2021-02-10)
有趣的是,如果我删除.toml
扩展,它的工作原理:
$ mv rust-toolchain{.toml,}
$ rustup show
Default host: aarch64-apple-darwin
rustup home: /Users/n8henrie/.rustup
installed toolchains
--------------------
stable-aarch64-apple-darwin (default)
nightly-aarch64-apple-darwin
active toolchain
----------------
nightly-aarch64-apple-darwin (overridden by '/path/to/cwd/rust-toolchain')
rustc 1.52.0-nightly (3a5d45f68 2021-03-09)
看起来 toml 扩展应该没问题,但不知道为什么它不起作用:
在这些情况下,可以在项目目录中名为 rust-toolchain.toml 或 rust-toolchain 的文件中命名工具链。
https://rust-lang.github.io/rustup/overrides.html?#the-toolchain-file https://rust-lang.github.io/rustup/overrides.html?#the-toolchain-file
它也适用于我只需要这个词nightly
,所以我不确定为什么它不适合你,但似乎这里可能有一些怪癖。
也许你可以尝试TOML
名为文件的语法rust-toolchain
?
编辑:看起来像.toml
扩展名是一个最近的发展 https://github.com/rust-lang/rustup/pull/2653,也许本书的更新是在工具更新之前发布的。
EDIT2:最新的 rustup 版本是 20201202 的 1.23.1,这就是我正在运行的版本,所以我的问题可能就在这里。您正在运行什么版本的 rustup?
https://github.com/rust-lang/rustup/releases https://github.com/rust-lang/rustup/releases