I propose improving the discoverability of, and the update process for, tools using Rustup. The proposal is a series of fairly minor changes, the most significant of which adds an extra stage (and some more options) to the first-run installation of Rust.
Rustup is a powerful tool for installing and updating Rust and its tools, and managing toolchains. It supports optional components including libraries, tools, source code, documentation, and data. However, Rustup was mostly designed and implemented before the tools ecosystem (other than Cargo and Rustdoc) was an important part of the Rust experience. Therefore, the experience with tools and Rustup is sub-optimal, especially for new users.
Primarily, we need better discoverability of tools; we believe that having the right tools will give new users a better experience of Rust. Since some tools can be missing from a nightly distribution, we should handle that case in a more user-friendly manner.
This RFC proposes several new Rustup features with different levels of impact and complexity. They are presented here in rough priority order of importance. None of these are breaking changes in most senses, though ‘tool stubs’ could have some problematic interactions with other software, described inline. I would be very glad to hear of other suggestions.
When first running Rustup (
rustup-init, usually via the rustup script of batch file) the user is presented with some options (for example, which toolchain should be the default). I propose adding another option, which ‘profile’ to use (I do not expect the word ‘profile’ to be user facing, since it is already somewhat overloaded by Cargo). The possible profiles would be:
- ‘minimal’ - just rustc, std, and Cargo (we might possibly want a ‘very minimal’ profile which is only rustc). Note that this would not include Rustdoc or the standard library docs which are included by default today.
- ‘default’ - ‘minimal’ plus Rustfmt, Clippy, Rustdoc, and the standard library docs. Note that this does not include the RLS and its supporting data, since that is usually installed by an editor plugin and is usually a good user experience. Using the RLS without an editor plugin is very rare.
- ‘complete’ - ‘default’ plus the RLS and it’s data (docs and save-analysis for the standard library), lldb on Linux, llvm-tools, and any other tools or data added as Rustup components in the future.
- ‘custom’ - ‘minimal’ plus interactively opt-in to each component
The profile is only used for first installation. If a component is later added to a profile, it will not be automatically installed for users who selected that profile.
If a user does not have a tool installed and tries to run it, then Rustup should suggest installing it. E.g., if the user runs
rustfmt but has not installed the Rustfmt component, then Rustup should inform the user that Rustfmt is not installed and offer to install it.
Implementing this should not be too difficult because Rustfmt creates symlinks to Rustup for all installed executables, it would just have to do this for executables which are not installed.
There is some backward compatability concern in the case that the user has installed a different executable with the same name already. However, Rustup is able to cope with this when a component is installed (by reporting an error to the user), and I think the same tactic could be used for components which have not been installed.
Better handling of missing tools
The current policy for tools other than Cargo and Rustdoc (currently Rustfmt, the RLS, and Clippy) is that PRs to the Rust master branch may land if they break a tool, except in the last week of a cycle (to ensure all tools are present for the beta fork). If a nightly should be released when a tool is failing to build or its test, it is not included in that nightly release (it is marked as
unavailable in the Rustup manifest). If a user has a missing tool installed, then an update will fail with an error, unless the user uses
--force. Similarly if a user tries to add a missing tool, then installation will fail with an error.
Some possible improvements:
- better error messages explaining what is going on (this is low-hanging fruit and doesn’t need an RFC, it’s included for completeness)
- display the current installation to make it easier to ‘unwind’ an update (potentially also offer a
rollbackcommand, though that is somewhat out of scope for this RFC)
- when a tool is missing, offer to update to the most recent release which has the tool
- an interactive mode so that users do not have to rerun with
--force. I’m not sure how to implement this: Rustup probably needs to remain non-interactive for default so that it can be used by tools and in CI.
- if we implement tool stubs as described above, then the stub could give a specific error message in the case that a component is missing.
- Any other ideas?
- Which of these need a formal RFC, vs just implementation?
- Do we need a formal policy or process for deciding which components to add to which profiles?