Support for rustup category home mode - #5056
Draft
Cloud0310 wants to merge 24 commits into
Draft
Conversation
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.
Contributor
Author
|
Fixed a minor CI/CD problem on Windows. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.