Repository navigation
Command for "install stuff from rust-toolchain.toml" #2686
Description
Activity
See #1397
I feel like there's value in keeping this issue different from #1397 for a couple of reasons:
-
The main point of
rustup showshould not force-install the default toolchain if it is not installed. #1397 is to disable a certain behaviour, this is to add that behaviour somewhere else (something that was discussed inrustup showshould not force-install the default toolchain if it is not installed. #1397, but isn't the main point) -
It's not clear to me from
rustup showshould not force-install the default toolchain if it is not installed. #1397 whether what's being discussed is installing just the toolchain per-se, or also the components that can be set in arust-toolchain.tomlfile. This issue is suggesting ensuring that everything specified inrust-toolchain.tomlis installed and available.
-
I think that ensuring
rust-toolchain{,.toml}is properly honoured is an all-or-nothing thing - it couldn't "just" be the toolchain itself, no matter what.You're right that #1397 is about ensuring that we don't over-indulge in autoinstallation, and I think this is a good home for how we then permit manual triggering of what was previously automatic.
I continue to think something like
rustup toolchain ensure [PATH]seems like a good approach, but further straw men for discussion would be good.I'm easy about the syntax.
rustup toolchain ensure [path]works for me.I was thinking re-using
rustup toolchain install, so:rustup toolchain install [toolchain]works as currentlyrustup toolchain install [path to rust-toolchain.toml]installs according to the specified filerustup toolchian install [path to directory]finds therust-toolchain.tomlthat would apply to that directory (if any) and asks for confirmation before installing, with the confirmation prompt specifying exactly which file and that you could have specified a toolchain instead.rustup toolchain installacts asrustup toolchian install .
Given all the other arguments
rustup toolchain installcan be given, I'd favour a separate verb.Reacted by Raphael Cohn and David SherretThere's a request to permit this during rustup-init as well; I've marked them as dup because I think its basically the same work... getting to a oneline for rustup not being installed is doable via:
rustup-init -y --no-update-default-toolchain && rustup toolchain ensure .(or whatever design we end up settling on).I'd also like to have
rustup-initbe able to read arust-toolchainfile to figure out what toolchain to install. In my specific use case, I'm install rust (viarustup-init) as part of my CI scripts. Currently I'm using:rustup-init.exe --no-modify-path --default-toolchain stable --profile minimal -ySince my
rust-toolchainfile listschannel = "1.59", rustup will end up installing thestablechannel (during initial install), and then later installing1.59(during the build).I could resolve this by manually keeping my CI scripts in-sync with my
rust-toolchainfile, but I'd prefer to just managerust-toolchain. (Another possible solution to my problem might to have something like--profile emptyas suggested in #2970. This would let rustup-init do some very minimal work and let the normal toolchain file mechanisms do the right stuff)@eminence just use
--default-toolchain nonethen ?Ah, sorry, I didn't know that was possible! I didn't see it listed in
--help, It'll give it a try!Given someone has actually started trying to implement this functionality, should we agree on syntax?
Based on the above, people seem to be keen for a new verb and have been using
ensure(and I'm not able to think of one I prefer right now), so let's move ahead with that and not bikeshed (it can easily be changed last minute if needed).As for exact syntax, based on my suggestion above I'd suggest:
rustup toolchain ensure [path to rust-toolchain.toml]installs according to the specified filerustup toolchian ensure [path to directory]finds therust-toolchain.tomlthat would apply to that directory (if any) and asks for confirmation before installing, with the confirmation prompt specifying exactly which file it's found.rustup toolchain ensureacts asrustup toolchian ensure .
I'd also suggest a confirmation prompt by default, listing the path to the file it's using and what it's about to install, with a
-y|--yesflag to skip the confirmation. Not a strong opinion on this one, if people don't like the confirmation then just do without.Are people happy with this? Anything we want to change?
Reacted by Trevor Grossrustup toolchain ensure [path to rust-toolchain.toml]installs according to the specified file
I want to chime in with a big yes for this. One reason I've been holding off on moving from the legacy
rust-toolchainfile torust-toolchain.tomlis because I rarely want CI to install all of the components that are nice to work by default in local development scenarios.If I could stash a CI-specific toolchain file in
.github/rust-toolchain-clippy.tomlor similar, I'd be able torustup toolchain ensure .github/rust-toolchain-clippy.toml, that would let me use the new format and still use more minimal toolchain files in CI environments.On a similar note, some of my projects use e.g. nightly rustdoc for building crate docs or nightly rustfmt which I invoke like:
rustup run --install nightly cargo doc --workspace rustup run --install nightly cargo fmt -- --color=autoUnfortunately this invocation doesn't let me specify components to install on the nightly toolchain and makes it more difficult to onboard new contributors to local development.
Is something like
rustup toolchain ensure path/to/toolchain.toml run ...something we can consider here too?Reacted by Brennan KinneyReacted by Brennan Kinney5 remaining items
@jmaargh I think adding an
ensurecommand like that would make sense, yes.- added a commit that references this issue
on Nov 20, 2023 @djc Are you a maintainer? I don't want to start working until maintainers have agreed in principle.
Reacted by Paul Lange@djc Are you a maintainer? I don't want to start working until maintainers have agreed in principle.
Yes (and so am I). Please go ahead with it! 🙏
- added a parent issue
on Mar 3, 2025
Apologies if this already exists, but I couldn't find it in the docs or shell help. Or if there is an alternate workflow for this.
I love
rust-toolchain.toml, it's a great idea. It would be even more useful if there were a command such asrustup override install, which would look at the currentrust-toolchain.tomland install the toolchain and components specified there. It would be super useful both when exploring projects for the first time, but also when using disposable container-based development environments.I'm unopinionated on the exact syntax of this command. Also happy to help implement this if the maintainers want it.