Skip to content

Support for rustup category home mode - #5056

Draft
Cloud0310 wants to merge 24 commits into
rust-lang:mainfrom
Cloud0310:xdg-final
Draft

Support for rustup category home mode#5056
Cloud0310 wants to merge 24 commits into
rust-lang:mainfrom
Cloud0310:xdg-final

Conversation

@Cloud0310

@Cloud0310 Cloud0310 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

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=1 or any non-empty value other than "0"):

Category Contents Platform Default
Cache downloads/, tmp/, update-hashes/ $XDG_CACHE_HOME/rustup or ~/.cache/rustup
Config settings.toml $XDG_CONFIG_HOME/rustup or ~/.config/rustup
Data toolchains/, fallback/ $XDG_DATA_HOME/rustup or ~/.local/share/rustup
State state.toml $XDG_STATE_HOME/rustup or ~/.local/state/rustup
Bin Proxies (rustc, cargo, etc.) Unix: ~/.local/bin
Windows: %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 in RUSTUP_HOME for toolchains.


Resolution Precedence

Note

This order still needs discussion, upon whether we should consider RUSTUP_HOME and CARGO_HOME. See open questions.

Design Guidance

We consider this as a breaking change, and RUSTUP_HOME as a purely legacy env
var, 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)

  1. RUSTUP_<CATEGORY>_HOME (if category mode is enabled)
  2. Platform category default (if category mode is enabled)
  3. RUSTUP_HOME (legacy shared override)
  4. $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

  1. RUSTUP_BIN_HOME (if category mode is enabled)
  2. Platform default bin directory (if category mode is enabled: ~/.local/bin)
  3. $CARGO_HOME/bin
  4. $HOME/.cargo/bin

Important Commits

feat(home): resolve category homes

Implements the core path resolution logic structured for future home crate compatibility across three layers:

  1. Underlying platform resolution: Handles Unix XDG environment variables and Windows native directories.
  2. home crate facade (mod home): Re-exports standard home APIs, implements RUSTUP_<CATEGORY>_HOME resolution and RUSTUP_HOME fallback without rollout logic.
  3. Rollout strategy: Implements the gating logic driven by 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 PATH setup now use rustup_bin_home, while generated shell environment scripts use the config home through rustup_env_home. Legacy mode preserves the existing $CARGO_HOME layout.

The commit also updates shell profile integration, Windows PATH handling, installer messages, and end-to-end coverage for the split layout.

Open Questions

  1. Windows Bin Location:

    • Currently set to %USERPROFILE%/.local/bin. Needs community consensus on whether this is the appropriate platform default for Windows.
    • Requires validating PATH precedence and migration UX from %USERPROFILE%\.cargo\bin.
  2. home Crate Compatibility:

    • Should category resolution eventually be upstreamed into the home crate, or should rustup maintain its own internal implementation permanently?
  3. RUSTUP_HOME is deprecated or not

    • Should we consider RUSTUP_HOME as an overall category override var?
    • Another option: consider RUSTUP_HOME as an overall category override variable,
      then resolution order is:
    1. RUSTUP_<CATEGORY>_HOME
    2. RUSTUP_HOME
    3. Platform category default

    overall variable. Then the the resolution order would be:

Following tasks

  • [] Create a cli interface for migration, rustup migration category-mode, for
    creating symlinks in legacy dir, pointing to coorresponding category dirs.
  • [] Add warning message for asking user for migrating to new category mode.
  • [] Update user-guide for new mode

@rami3l rami3l self-assigned this Sep 5, 2026
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.
@Cloud0310

Copy link
Copy Markdown
Contributor Author

Fixed a minor CI/CD problem on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants