Repository navigation
Closed
Labels
Description
Problem
#3475 adds a warning when the machine and user Path together expand past 3700 characters. The warning says the Path is too long. It does not say which entries are safe to remove, so the operator works that out by hand.
The maintainer scoped #3475 to the length check and moved the rest of its proposal here.
Scope
The maintainer set this scope on 2026-11-04. It replaces the read-only proposal this issue first carried.
- Clean the
Path, not just report it. Remove dead entries and duplicates. This reverses the stance inhost-setup/windows/README.md"The Path Length Warning" that neither script editsPath, so that section changes with it. - The owner is
upgrade-host.ps1.-Statuslists what a cleanup would remove. A new action removes it after the script's usual confirmation, and honors-DryRunand-Yes. The menu gains an entry for it. - Elevation is detected, never required. The action tests whether it is running elevated and never fails on either answer.
- Unelevated: it cleans the user
Path, lists the machine findings, and tells the operator that removing those needs an elevated run, such as the same command undergsudo. It exits successfully. - Elevated: it cleans both halves. An operator who runs this under
gsudogets the full cleanup with no extra step. - Never: the script raises no UAC prompt and refuses no run for its elevation state. This keeps the README's "Elevation and Scope" rule.
- Elevated as another account: the user half is that account's
Path, not the signed-in user's. The README already names this hazard for a user-scope install made from an elevated process. So an elevated run writes the user half only when the elevated identity is the interactive session's user. Otherwise it cleans the machine half, lists the user findings, and says why.gsudo's default elevates the same user, so this case does not arise there.
- Unelevated: it cleans the user
- Out of scope: asking Explorer whether it actually dropped the user
Path(theRegenerateUserEnvironmentprobe), and finding fully shadowed entries. Removing a shadowed directory can drop a DLL or a script that something else loads.
What Counts
- Duplicates, within machine, within user, and between the two. Compare after expansion, case folding, and trimming a trailing
\or\.. The first occurrence in effective order (machine, then user) is kept. A user entry duplicating a machine entry is removed from the user half. - Dead entries, an entry whose expanded path does not exist. An entry is dead only when its drive or share root answers and the directory does not. An unreachable root (an unmounted drive, an offline share) is listed and kept, since a state that could not be read is never reported as an absence.
- Empty entries, from a doubled or trailing
;.
Constraints on the Write
- Read and write each scope's raw registry value, keeping
REG_EXPAND_SZand every entry's unexpanded form. Writing the expanded$env:Pathback would freeze%USERPROFILE%and similar variables into literal paths. - Print the previous value before writing, so a bad cleanup can be restored by hand.
- Broadcast
WM_SETTINGCHANGEafter a write, so new processes see the change without a sign-out. - Order is otherwise preserved.
Done Means
upgrade-host.ps1carries the action, its-Statuslisting, and-Helptext, with the README and the menu updated to match.- Tests cover the duplicate rules, the dead-versus-unreadable split, the unexpanded round trip, the elevated-versus-unelevated split with its notice and success exit, and the other-account case. They run against a stubbed registry read and write rather than the host's real
Path. - Native Windows runs of
-Statusand of-DryRunwith the action, both unelevated and undergsudo, are recorded in the pull request.
Activity
Warn When the Windows Host Path Nears the Length Explorer Drops (#3863)
Promote Develop: Warn When the Windows Host Path Nears the Length Exp…
[-]Name Which Windows Path Entries to Remove and Whether Explorer Dropped the User Path[/-][+]Remove Dead and Duplicate Windows Path Entries From upgrade-host.ps1[/+]ptr727 commentedon Nov 4, 2026
Rescoped by the maintainer on 2026-11-04. The Explorer probe and the shadowed-entry check are dropped. Dead and duplicate entries are now removed rather than only reported, by a new
upgrade-host.ps1action, with the machine half written only from an elevated run. The previous body proposed four read-only checks, and the body now states the new scope whole.ptr727 commentedon Nov 4, 2026
Elevation clarified by the maintainer on 2026-11-04. The action detects elevation and never requires it. An unelevated run cleans the user half, names the machine findings, says an elevated run such as
gsudoremoves them, and exits successfully. An elevated run,gsudoincluded, cleans both halves and never fails for being elevated. The body's Scope section now states this, with the case of elevating as another account.Remove Dead and Duplicate Windows Path Entries From upgrade-host.ps1 (#…
Keep a Drive Root's Separator and Judge a Literal Percent in Path Cle…