Support for rustup category home mode - #5056
Conversation
|
Fixed a minor CI/CD problem on Windows. |
This is an alternative design commit and will be rewritten later. In category mode, resolve RUSTUP_<CATEGORY>_HOME first, then platform defaults, ignoring RUSTUP_HOME. Keep legacy resolution when category mode is disabled. Include the corresponding documentation, installer messages, test-environment isolation, and focused regression tests.
|
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 |
|
☔ The latest upstream changes (possibly #5064) 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).This prevents rustup from adhering to platform-standard directories (XDG on Unix, Known Folders on Windows).
This PR introduces an opt-in category-home layout guarded by
RUSTUP_USE_CATEGORY_HOME, while preserving the legacy single-directory 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/rustupsettings.toml$XDG_CONFIG_HOME/rustupor~/.config/rustuptoolchains/,fallback/$XDG_DATA_HOME/rustupor~/.local/share/rustupstate.toml$XDG_STATE_HOME/rustupor~/.local/state/rustuprustc,cargo, etc.)~/.local/binWindows:
%USERPROFILE%/.local/bin(tentative)Important
Why gated?
Gating both category overrides and platform defaults avoids split-brain installations where external tools (e.g. older
rust-analyzer) still look exclusively inRUSTUP_HOMEfor toolchains.Resolution Precedence
Note
This order still needs discussion, upon whether we should consider
RUSTUP_HOMEandCARGO_HOME. See open questions.Design Guidance
We consider this as a breaking change, and
RUSTUP_HOMEas a purely legacy envvar, so in new mode, we don't use it anymore, so, on category mode available,
the fallback paths are ignored.
Categories (Cache / Config / Data / State)
RUSTUP_<CATEGORY>_HOME(if category mode is enabled)RUSTUP_HOME(legacy shared override)$HOME/.rustup(legacy fallback)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
RUSTUP_BIN_HOME(if category mode is enabled)~/.local/bin)$CARGO_HOME/bin$HOME/.cargo/binImportant Commits
feat(home): resolve category homes
Implements the core path resolution logic structured for future
homecrate compatibility across three layers:homecrate facade (mod home): Re-exports standardhomeAPIs, implementsRUSTUP_<CATEGORY>_HOMEresolution andRUSTUP_HOMEfallback without rollout logic.RUSTUP_USE_CATEGORY_HOME.feat(uninstall): remove legacy and category rustup homes
Removes rustup home directories (config, cache, data, state) for both legacy and category layouts. (Excludes bin directory).
feat(uninstall): clean legacy and category cargo bin homes
Cleans up rustup-managed proxy binaries and symlinks across both legacy and category bin directories, leaving unrelated user binaries untouched.
feat(installer): migrate bin and env paths to split homes
Completes the installer-side migration from Cargo-owned paths to Rustup's resolved homes. In category mode, rustup binaries, proxy links, self-update artifacts, executable checks, and child-process
PATHsetup now userustup_bin_home, while generated shell environment scripts use the config home throughrustup_env_home. Legacy mode preserves the existing$CARGO_HOMElayout.The commit also updates shell profile integration, Windows
PATHhandling, installer messages, and end-to-end coverage for the split layout.Open Questions
Windows Bin Location:
%USERPROFILE%/.local/bin. Needs community consensus on whether this is the appropriate platform default for Windows.PATHprecedence and migration UX from%USERPROFILE%\.cargo\bin.homeCrate Compatibility:homecrate, or should rustup maintain its own internal implementation permanently?RUSTUP_HOME is deprecated or not
RUSTUP_HOMEas an overall category override var?RUSTUP_HOMEas an overall category override variable,then resolution order is:
RUSTUP_<CATEGORY>_HOMERUSTUP_HOMEoverall variable. Then the the resolution order would be:
Following tasks
rustup migration category-mode, forcreating symlinks in legacy dir, pointing to coorresponding category dirs.