rustup: Tracking: Rustup should not perform implicit installations
Problem you are trying to solve
here is a transcript of a session with rustup
PS C:\Users\jyn\src\example> rustup toolchain list
nightly-x86_64-pc-windows-msvc (default)
1.74-x86_64-pc-windows-msvc
stage1
PS C:\Users\jyn\src\example> rustup uninstall nightly
info: uninstalling toolchain 'nightly-x86_64-pc-windows-msvc'
info: toolchain 'nightly-x86_64-pc-windows-msvc' uninstalled
PS C:\Users\jyn\src\example> rustup toolchain list
1.74-x86_64-pc-windows-msvc
stage1
PS C:\Users\jyn\src\example> rustc
info: syncing channel updates for 'nightly-x86_64-pc-windows-msvc'
info: latest update on 2024-01-07, rust version 1.77.0-nightly (b6a8c762e 2024-01-06)
info: downloading component 'cargo'
^C
PS C:\Users\jyn\src\example> rustc +nightly
error: toolchain 'nightly-x86_64-pc-windows-msvc' is not installed
PS C:\Users\jyn\src\example> rustup --version
rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: syncing channel updates for 'nightly-x86_64-pc-windows-msvc'
Proposed Solution & Progress
[The following behaviors of the current rustup should be changed:]
- uninstalling the default toolchain happens silently. i would expect either a warning (by the same logic as https://github.com/rust-lang/rustup/issues/3319), or for rustup to switch to a different default toolchain.
- running
rustcafterwards implicitly reinstalls the toolchain. -
I do not expect rustup to implicitly install in any case other than when[@rami3l: We shouldn’t do even that, instead we should let the user explicitly install the required toolchain with a command.]rust-toolchain.tomlis in the current directory. in fact, you can see thatrustc +nightlydoes not implicitly install, onlyrustcby itself. - running
rustup --versionalso silently installs. - running
rustup showalso silently installs.
Notes
rustup 1.26.0 (5af9b9484 2023-04-05)
Tasks
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 64 (49 by maintainers)
I think as interactive prompt when a tty is attached might be good, but we should definitely:
i would be happy with that. i originally wrote in this issue
but i no longer feel as strongly about that; i only feel that—in the case where there’s no
rust-toolchain.tomlin the current directory—rustcandrustc +toolchainshould be consistent with each other about whether they implicitly install.@samestep makes some good points. So what was the rationale for not implicitly installing a toolchain?
rustup showshould not implicitly install a toolchainrustup --versionshould not implicitly install a toolchainSo maybe the guideline should be that
rustupcommands should never implicitly install, but invocations of the proxy should?Oh for old powershell I’d do it like:
@ickk It’s a perfectly reasonable suggestion. Let’s think about the available options together and find out how to do this properly.
@LukeMathWalker It’s a recent change in https://github.com/rust-lang/rustup/pull/3983. The actual syntax is suggested by @ChrisDenton IIRC.
We have also updated the help message:
@LukeMathWalker You’d do
rustup toolchain install/rustup install(without any arguments) to manually install the active toolchain starting from v1.28.0. I promise we’ll deliver the new release notes with a huge emphasis on this change.rustup installNote the use of “effectively”. 😉
(not reading up on the thread but as I was pinged) r-a would likely benefit from an explicit install step. I’m annoyed with checking out a repo that has a toolchain override in it just for r-a to hide the installation behind a
fetching metadatastep as its being installed while r-a invoked cargo metadata. Even better would be if we could query whether there is an override for the given dir so we could prompt the user (if desired, otherwise fallback to installing ourselves). Likewise was was said, having rustup management integration in the IDE would be nice as well (which would require querying more state about rustup things as well)Oh also being able to query whether the toolchain for the dir needs to be installed of course
The experience Daniel and I had over 5 or so years of supporting users here has been that rustup going out to the internet unpredictable is a significant problem.
Consider this breakdown instead:
Separately, goenv, pyeng, nodenv - and others - all have an explicit model, and I haven’t seen any frustration at that on the 'net.
tl;dr, I think this is being over-thought! do we have any actual data of people using main and being unhappy with it?
So zooming out: IMO if we introduce the need for
rustup installwhere previously onlycargo checkwas sufficient, or even if we introduce a prompt that asks for installation of the toolchain and users opt to run the suggested command or confirm the prompt like 99% of the time, then IMO we’ve made things worse for them. So I wonder, do we think this is a likely scenario?I actually think the case of running
cargovia Rust-Analyzer is another good reason that implicit installations for common commands that it uses is a good thing, as a suggested command will not be as easily accessible when you’re running RA in your IDE and now it’s even more of a context switch.(I think we should avoid mixing #988 into this issue – yes, that can happen, but it happens today and there would still be other ways it can happen if we require explicit toolchain installations.)
So I think there are like 5 paths potential ways to go:
After two more weeks of consideration, I still like (5) best:
Downsides:
We could also introduce a new environment variable (
RUSTUP_IMPLICIT_INSTALL?) that could be used to disable implicit installations entirely which could help (separately from anything else).@Veykril do you have opinions from the RA side of things?
That’s fair.
While optimizing for consistency and fewest surprises makes sense, I’m inclined to agree with @samestep that this might come at a non-trivial cost to developer experience, where
cargo checkrequires a manual rustup invocation after someone updates the toolchain version in arustup-toolchain.tomlin your repo. I suppose this might happen with some regularity in projects that use nightly versions. So I don’t think it’s crazy to wonder about refined heuristics here.@samestep in your experience, how often is the toolchain updated in projects you work on? Do you think it would still be prohibitive if the change was instead to put up an explicit prompt that you could just Enter on to move forward with installing the new toolchain?
Not sure, allowlisting (I think we prefer to use “whitelisting” these days) both
--version/-Vand--printmight still make sense? Or we could just decide that--version/-Vis special because it is more often used as a sort of probe.@ickk The message is already there, as per the description in https://github.com/rust-lang/rustup/pull/3985:
https://github.com/rust-lang/rustup/blob/e857897d74215c6f33db7b7360fbbb12a89b46b3/tests/suite/cli_v2.rs#L320-L336
If the maintainers’ current plans are to remove implicit install behaviour altogether (that’s how this issue reads - I don’t necessarily agree with this, but w/e), a short message describing how to install the missing toolchain would pretty much be just as easy for the user
that’s not what @samestep’s question is about, though. they’re asking about what version of cargo implicitly gets run when there’s a rust-toolchain file in that folder.
@samestep i don’t know; i haven’t been following this issue closely. you’d need to ask the rustup maintainers.
@ChrisDenton My understanding is that it is expected to do anything
rustc --versioncurrently does before actually running that command on the correspondingrustc, it’s just that everything will become explicit now. So yes, this includes (and isn’t limited to) installing the toolchain specified in therust-toolchain.tomlfile.Yes! As the two subcommands has been unified with #3596, that looks like a less painful move indeed. A single change for these two places!
@rami3l I’m not clear exactly where the plan is at on this, but with respect to this comment I think that convenience is how we got to the current place.
I believe it is much easier to write tools on top of very predictable systems, and that there is a convenience argument for implicit installs throughout. My suspicion (not validated via research) is that having no implicit installs, one command ensure that a toolchain is installed, is enough.
I have previously written about having one command to install, where an existing install is an error, and one to ensure an install, but I’m struggling to think of a place where the error ‘cannot install toolchain X, it is already installed’ would be useful. There is a clear nearby-case of linked toolchains where X can mean anything, but having a single command that errors when the linked path is different in that case, and has a
--forceoverride, seems like it would be sufficient.@Doineann Thanks for your feedback! Yes, what you said is part of what we want to change with this issue, see the 2nd point.
sounds good to me 😃
@jyn514 Thanks a lot for filing this issue! I see basically two points being made here:
This is a nice suggestion, and I’m looking forward to implementing it 😃
As for removing implicit installations, it’s already on our list (https://github.com/rust-lang/rustup/issues/3546#issuecomment-1831292725), but it seems to me that a separate issue hasn’t been created yet.
Would you mind if I split this issue into two so that they can be tracked separately? I personally suggest use #3546 to track the removal of implicit installations, and move the first point over to #3319. Does that sound okay to you?