Repository navigation
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
About Windows' bin directory location problem, here's more context:
@ChrisDenton @rami3l , Current PR's defaulting to use |
|
Hm, since I feel one of the points of this feature is to use more platform native paths, I don't think I think either of the other two options are justifiable. Putting it under "Programs" is the most technically correct I guess but if anything there's a weaker precedent for that, albeit applications that used to support XP wouldn't have used it because "Programs" wasn't a thing back then. |
|
What are we doing for macOS here? The XDG stuff definitely doesn't feel native for it. |
|
There appears to be a fairly strong use of XDG for macOS cli utilities. I cannot find any officially documented conventions that aren't intended for app bundles but unofficially almost everything in the shell seems to treat it as a Unix (which it is). |
That's what @rami3l and I wants as well. |
|
In terms of precedence of different configuration options, as I have discussed with @Cloud0310, the only remaining concern is what to do when As per the previous summary in https://blog.rust-lang.org/inside-rust/2025/10/01/this-development-cycle-in-cargo-1.90/#all-hands-xdg-paths:
This means
|
AFAIK the standard library currently uses the same logic for macOS and Linux, so I think that is a very good default to start with: https://doc.rust-lang.org/stable/std/os/unix/xdg/fn.cache_home_dir.html Also, this is the convention followed by other existing tools such as neovim and uv. I am aware of the frequently-quoted macOS documentation page which to some may suggest paths like I would again point out (as @ChrisDenton has mentioned above) that these guidelines are specific to app bundles (that page is full of app bundle-specific paths, with If the user really prefers to place stuff in |
This also has an effect on the env var recursive forwarding system, I guess once we're in new mode, I need to stop forwarding |
@Cloud0310 Exactly, and I'd like to see more regression tests on this point to make sure that we have done the right thing. |
|
For macOS, I'm particularly concerned about the cache directories. If we don't put them in the location that the OS understands, we basically don't get to benefit from the OS managing caches, which seems bad. For binaries, won't it cause issues if we share a |
@djc What potential issues do you have in mind to be precise?
I am aware of special macOS mechanisms that may force the shrinking of |
@epage what's cargo's decision here? Maybe we want to sync this "favor" choice with cargo team. |
|
@epage Note that we are not pressuring cargo to do the final decision because in the opt-in period we can still change the default value, but it'd be interesting to see if we can land on something in common first. @Cloud0310 For Windows’ bin dir my personal preference would be the option 2 (PNPM) above. |
|
I think the commit history here could stand to be improved. Would suggest:
|
Untill we finally out of opt-in period and settle on this choice, I would just keep using |
This comment has been minimized.
This comment has been minimized.
445ebaf to
5108cf3
Compare
This comment was marked as outdated.
This comment was marked as outdated.
acea6f2 to
ceba2fa
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I have carefully assessed your patch and especially all the behaviors related to the case where RUSTUP_USE_CATEGORY_HOME=1 is not set, and I think the chances of breakage are minimal.
As such, I think it is time to approve it now. Any further changes to the feature could be addressed in follow-up PRs.
Before actually merging it, I'd like you to make sure that the PR description is up to date and matches your current implementation (some details such as the bin_path on Windows have been changed during your iterations, for example). It will help anyone who comes after to have the right full picture.
Many thanks again for participating GSoC 2026 to help us out with rustup and all the iterations you have done!
I still have some little nits for refine, and the PR description update is on it's way here. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
☔ The latest upstream changes (possibly #5142) made this pull request unmergeable. Please resolve the merge conflicts. |
Related to #247.
Summary
Rustup historically stores configuration, state, data, and caches under a single
RUSTUP_HOME(defaulting to$HOME/.rustup), while rustup and its proxies are installed underCARGO_HOME/bin.This PR introduces an opt-in category-home layout guarded by
RUSTUP_USE_CATEGORY_HOME, while preserving the legacy layout by default.When category mode is enabled (
RUSTUP_USE_CATEGORY_HOME=1or any non-empty value other than"0"):downloads/,tmp/,update-hashes/$XDG_CACHE_HOME/rustupor~/.cache/rustupWindows: Local AppData
rustupsettings.toml$XDG_CONFIG_HOME/rustupor~/.config/rustupWindows: Roaming AppData
rustuptoolchains/,fallback/, generated shell env scripts$XDG_DATA_HOME/rustupor~/.local/share/rustupWindows: Roaming AppData
rustupstate.toml,self-update/$XDG_STATE_HOME/rustupor~/.local/state/rustupWindows: Roaming AppData
rustuprustc,cargo, etc.)~/.local/binWindows:
%USERPROFILE%/.local/bin(tentative)Important
Why gated?
Gating both category-specific overrides and platform defaults avoids split-brain installations where external tools still look exclusively in
RUSTUP_HOMEfor toolchains.Enabling category mode selects the new locations; it does not migrate an existing installation.
Resolution Precedence
Note
Explicit
RUSTUP_HOMEandCARGO_HOMEsettings remain in the resolution order for backward compatibility. Category-specific overrides and platform defaults are only active when category mode is enabled.Design Guidance
The legacy layout remains the default. Category mode splits Rustup's resources across independently resolved homes while preserving explicit legacy overrides.
This PR does not redefine
RUSTUP_HOMEas a common base directory for every category, and the binary directory does not fall back toRUSTUP_HOME/bin. Further changes to those semantics can be considered separately after the category layout is rolled out.Categories (Cache / Config / Data / State)
In category mode:
RUSTUP_<CATEGORY>_HOMERUSTUP_HOMEWhen category mode is disabled, category-specific overrides are ignored and all four categories use the resolved legacy
RUSTUP_HOME.Note
On Unix, explicit absolute
XDG_variables take precedence over$HOME-derived paths. Empty or relative XDG values are ignored.Windows does not consult XDG variables.
Bin Directory
In category mode:
RUSTUP_BIN_HOMECARGO_HOME/binWhen category mode is disabled, Rustup continues to use the resolved legacy
CARGO_HOME/bin.The current category-mode default is
~/.local/binon Unix and%USERPROFILE%/.local/binon Windows. The Windows default remains open for discussion.Important Commits
feat(home): resolve opt-in category homes
Implements the directory resolution rules and opt-in rollout strategy across three layers:
process.rsselects the legacy or category layout throughRUSTUP_USE_CATEGORY_HOME.process/home.rsapplies category-specific overrides, explicit legacy overrides, and platform defaults.process/home/{unix,windows}.rsresolves XDG directories on Unix and Known Folders on Windows.The gate controls both the new category-specific overrides and the platform defaults. When it is disabled, the existing
RUSTUP_HOMEandCARGO_HOMEbehavior remains unchanged.fix(toolchain): preserve legacy home forwarding across home modes
Defines how Rustup's resolved directory choices are passed to toolchain child processes.
Toolchain commands receive the resolved config, data, cache, state, and bin homes through their corresponding environment variables. Legacy mode continues to forward
RUSTUP_HOME, while category mode forwards the resolved category homes instead.Rustup also sets
RUSTUP_TOOLCHAINand places the resolved proxy directory at the front of the child process'sPATH, so later Cargo, rustc, and proxy invocations use the same toolchains and directory selection as the parent process.CARGO_HOMEremains separate from Rustup's category homes. Legacy mode preserves the existing resolution and forwarding behavior; category mode resolves and forwards it when the variable is explicitly present.feat(shell): use env home for installation scripts and setup
Generated shell environment scripts use the data home in category mode and the Cargo home in legacy mode.
Script generation, shell profile entries, post-install instructions, and uninstall cleanup use the resolved env home. The scripts themselves add the independently resolved bin home to
PATH; they no longer assume that the env scripts and Rustup binaries share a parent directory.With the default Unix category layout, a POSIX shell sources
~/.local/share/rustup/env, which adds~/.local/bintoPATH.fix(windows): make uninstall GC independent of installation directories
Runs the Windows uninstall GC helper from an independent regular-file copy in the system temporary directory.
This avoids requiring write access to the parent of
CARGO_HOMEor another installation directory. Copying the executable contents instead of preserving a symbolic link also ensures that the delete-on-close handle targets the temporary GC copy rather than the installed rustup executable.The GC helper attempts its own cleanup even if uninstalling the Rustup installation fails.
feat(uninstall): clean legacy and category installations
Legacy mode retains the existing Rustup and Cargo home cleanup behavior.
In category mode, uninstall removes the current toolchains, generated shell environment scripts, and rustup-managed binaries without treating the category homes or bin home as exclusively owned by Rustup.
Proxy removal uses same-file checks against the installed rustup executable. Unrelated files are preserved, a non-empty shared bin directory is left in place, and a separate legacy installation is not removed as part of category-mode uninstall.
Open Questions
%USERPROFILE%/.local/bin.PATHprecedence, and migration from%USERPROFILE%/.cargo/bin.Following tasks