Some days ago, when Rust 1.47.0 was released, I installed it using a current version of
I played a bit around, roughly I did the following
rustup toolchain install "1.46.0"
Create a rust project under '
~/develop/test/' and change to that directory.
Set a directory override with '
rustup override set "stable"'.
Then I pinned the project to a specified release using a
rust-toolchain file with '
echo "1.46.0" > rust-toolchain'.
When I run
rustc I was a little bit surprised because I expected the pinned Rust version "1.46.0" NOT the current stable "1.47.0".
I checked it by running '
rustup show' and '
Both calls show me that the Rust version for the test project was the current "stable" release "1.47.0" (set with rustup override) NOT the pinned version "1.46.0" which I expected.
In the documentation is written that a directory override has a higher priority than a
1. A toolchain override shorthand used on the command-line, such as cargo +beta. 2. The RUSTUP_TOOLCHAIN environment variable. 3. A directory override, set with the rustup override command. 4. The rustup-toolchain file. 5. The default toolchain.
My question now is, why have a directory override a higher priority than a local
rust-toolchain file (if they point to the same directory)? What is the idea behind such a behavior?
Would it make sense to swap the priority for a directory override and a rust-toolchain file? Maybe such a behavior would feels more natural.
Swap the priority maybe have following advantage:
If a shared project was updated with a new
rust-toolchain file to a newer Rust version, everyone automatically use the new version, even if the project directory was overridden with an different version using '
A prominent example is Git, which can also optionally use a local project configuration
.gitconfig, which have a higher priority than the other local and global config files.
rust-toolchain are designed to be shared in a project repository.
The following table compare the priority of the Git and Rust configurations.
|Prio.||Git config||Rust config||Description|
||Directory override '
||Local Git config file; local Rust settings in global config.|
||Local config files.|
||Default toolchain '
||Global config files.|
.gitconfig file will only be used by Git when calling the following command once.
git config --local include.path ../.gitconfig