Conversation
|
Fixed a minor CI/CD problem on Windows. |
|
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
|
Self reviewed and checked again, also changed the resolution order as comment. And as for the forwarding system, I added extra conditions for making sure backward compatibility. |
faf9239 to
b3373a9
Compare
b3373a9 to
a514e2b
Compare
This comment has been minimized.
This comment has been minimized.
Pass bin directories to binary, proxy, and updater helpers, and pass the resolved Cargo home to Windows uninstall GC. Give shell script helpers separate env and bin directory inputs while preserving legacy home-variable spelling.
Pass resolved env and user-home paths into source-line rendering. Share exact source-line removal and reuse the current operation paths and legacy rcfile candidates during cleanup.
a514e2b to
f15d003
Compare
Keep canonical_cargo_home and accept resolved paths without renaming it. Pass complete bin and env directory text to the templates, share post-install wording across platforms, and reuse the resolved homes for source commands. Keep display formatting separate from filesystem paths and use native separators in the uninstall message.
Copy the running executable into a regular temporary file. Keep temporary path ownership until the delete-on-close handle takes over cleanup.
Create GC outside Cargo home so uninstall does not require write access to its parent. Update the cleanup test to inspect the system temporary directory.
Resolve category overrides and platform defaults behind RUSTUP_USE_CATEGORY_HOME. Preserve legacy overrides and defaults, and use Process for installer and uninstaller home resolution. Cover Unix and Windows resolution rules.
Generate shell source commands with resolved paths. Recognize historical source commands during setup and cleanup, with compatibility coverage.
Use the resolved cache home for downloads, temporary files and update hashes. Forward the resolved home to child processes and cover cache placement.
Use the resolved data home for installed toolchains and fallback commands. Forward the data home to child processes and cover both storage paths.
Create the state directory and read and write state.toml there. Forward the resolved home to child processes and verify persistent release-hint state.
Read and write settings in the resolved config home, including installer checks. Initialize config and state without creating an unused legacy home, and cover split-home installation and settings persistence.
Remove the unused legacy home from Cfg. Preserve explicit legacy overrides without injecting resolved defaults into category-mode child environments, and cover operation without a resolvable legacy home. Verify resolved category homes are forwarded for unset, empty and explicit overrides.
Use resolved bin and env homes for installation, proxies, self-update, PATH and Windows registration. Display split homes with BinHomeDisplay and cover installation and shell setup with category overrides.
Show resolved category directories in rustup show and rustup show home. Preserve legacy output and update help snapshots and CLI coverage.
Remove legacy and category homes and Rustup-owned binaries from both bin directories. Preserve unrelated programs, honor --no-modify-path, and cover shared directories and cleanup after removing the working directory.
f15d003 to
721b6b1
Compare
|
☔ The latest upstream changes (possibly #5096) 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)$CARGO_HOME/bin~/.local/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
%USERPROFILE%/.local/bin. Needs community consensus on whether this is the appropriate platform default for Windows.PATHprecedence and migration UX from%USERPROFILE%\.cargo\bin.Following tasks
rustup migration category-mode, forcreating symlinks in legacy dir, pointing to coorresponding category dirs.