Rustup: The toolchain file overrides `rustup install`

Created on 17 Oct 2019  路  7Comments  路  Source: rust-lang/rustup

Describe the problem you are trying to solve
Current rustup install requires a positional parameter <toolchain> even if I have a toolchain file.

I have a file rust-toolchain file (ex: 1.37.0) at the root of a repository. I know that cargo installs it automatically:

cargo build # The toolchain is automatically installed as overridden by `rust-toolchain`

But I want to separate the install step from the build step:

# install:
rustup install 1.37.0
cargo fetch

# build:
cargo build

I have to change the versions in the script and rust-toolchain file when I want to update the toolchain. I might be able to do like rustup install $(cat ./rust-toolchain), but sometimes it is not easily feasible to do in multi-platform CI environments.

However, rustup show does exactly what I wanted:

# install:
rustup show # It installs 1.37!?
cargo fetch

# build:
cargo build

I think rustup install should also do that.

Describe the solution you'd like
rustup install should install the overridden version when

# install:
rustup install # It installs the overridden version.
cargo fetch

# build:
cargo build

Notes
rustup install and rustup toolchain install seem to be aliases for rustup update.

enhancement

All 7 comments

I'm not entirely sure how we'd make that work with clap, without introducing more complex logic to somehow provide an optional value where absence is validated only if there's a valid override available.

The rustup toolchain install command is more about explicitly choosing a toolchain to install, rather than being driven by a directory override of some kind.

Thank you for your reply. I understand that you prefer the explicitness for the command.
Then, would you let me know what you think about the rustup show's behavior? It automatically installs toolchains driven by a directory override. Was it intended behavior?

Basically whenever rustup tries to find a toolchain it has implicitly been told should exist, it will force an installation if it cannot find it. Thus cargo build will automatically install a toolchain where needed, etc. rustup show happens to need to find the active toolchain in order to print out its version information, hence it ends up installing it. It is intended behaviour, yes.

Thank you for letting me know that. I'll close this issue.

Could this be at least documented more visibly? Just got quite confused by this issue and initially didn't notice that toolchain can be installed using rustup show.

@Kixunil I have filed #2639 to that effect.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings