-
Notifications
You must be signed in to change notification settings - Fork 941
Default implicit install restrictions #4264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@ChrisDenton sorry I wasn't able to give feedback on your earlier proposal. I think we should extend this substantially before we give it wider exposure, and I'm honestly more and more inclined to use the project RFC process for it. Feedback on the current content:
Should also discuss interaction with the safe directories RFC. |
My intent here is to gather feedback (definitely including substantial edits!) rather than going straight to a full RFC. An RFC seemed somewhat premature to me if there's still a lot of questioning of the premise and many ideas about which direction to go in. I definitely want to focus on the background/problems sections more than specific solutions at this point so expanding that is very useful.
As an eventual goal, I agree. However for a "next step", I fear changing what |
I am ambivalent about this kind of phasing. In a way, I think a single transition is helpful because you don't need users to update their stuff multiple times in (shortish) succession. |
The intent of the next steps is that almost nobody will need to change anything. Use of |
Summary
This issue is intended to gather community feedback on the future direction of rustup's automatic install behaviour. It suggests some changes to the way rustup does implicit installs by default but these proposals are subject to change based on feedback.
Background
Currently
rustup
will implicitly install the active toolchain if it isn't installed already. This happens when you run almost anyrustup
command or using a tool managed by rustup, such ascargo
orrustc
(these are called "shims").The active toolchain is usually controlled by the user. but, as detailed on the Overrides page of the book, a project can contain a
rustup-toolchain.toml
file to override the user's preference.In this example of an override, we set the toolchain to use
nightly-2025-03-20
for their current host:A toolchain override can also be a path to a custom toolchain:
Users can override this override using the
+
syntax (e.g.cargo +stable build
) or by usingrustup override
.Different projects use a
rustup-toolchain.toml
for different purposes. For example:How
rustup
is usedrustup
is used in a variety of different contexts which may have different requirements. For example:Additionally
rustup
can be used when either the user or systems has resource constraints:Problems
Silent background installs
As mentioned above, IDEs use
rustup
in the background when they callcargo
orrustc
. This means that toolchains can be installed completely silently. This also means that downloads are more likely to occur concurrently with other uses of rustup. This can currently cause errors and other problems due to lack of filesystem locking but even when that is fixed it will cause the user to be blocked until the IDE finishes downloading a toolchain.Trust
The current default implicitly trusts the
rustup-toolchain.toml
file. Since it's common to download projects from the internet, this is not a great default. Making this worse is thepath
override, which can mean implicitly trusting binaries downloaded from the internet without user intervention.Control
Users should ultimately be in control of which toolchains are installed and used.
While it is possible to override
rustup-toolchain.toml
usingrustup override
, this isn't easy to discover naturally and in any case requires a lot more vigilance. The+
syntax can also be used as an override but this requires remembering to use it for every single command that goes throughrustup
.Next steps
These steps are intended to have minimal impact on current uses of rustup but take care of some edge cases. They do not address all the above issues.
rustup-toolchain.toml
uses apath
based toolchain then this will always require an explicit install if it's not installed already.cargo
, should implicit installs happen. Explicit installs can be done via therustup install
command.rustup
commands should cause an implicit install (e.g.rustup --version
).Future possibilities
Trusting
rustup-toolchain.toml
It would be good for the user to be given a choice on how they want to handle a
rustup-toolchain.toml
file in a project. E.g.:rustup-toolchain.toml
file. This will mean changes in the file can cause implicit installs of new toolchainsThis would allow the user to have control over what gets installed on their system and to be able to easily user their preferred toolchain. The difficulty will be in providing a migration path, especially for CI.
Using
--version
on shimsUsing
--version
on shims (such ascargo --version
) should not trigger a download and install. People who use this intentionally to install toolchains should be migrated torustup install
, first with warnings and later becoming a hard error.Unanswered questions
Interaction with the "safe file discovery" RFC
The Cargo and Rustup safe file discovery RFC proposes limiting the directories visited by
cargo
andrustup
to just those owned by the user to protect against other users on the same system being able to tamper with the current users' builds. It suggests theRUSTUP_SAFE_DIRECTORIES
andCARGO_SAFE_DIRECTORIES
environment variables to opt-out of this. Should rustup reuse these for other meanings of "safe" or would conflating these concepts be confusing?Prior art
direnv
is a tool that allows environment variables to be configured using a file in the current directory. Users must usedirenv allow .
to allow this and do so again for changes.The text was updated successfully, but these errors were encountered: