Skip to content

fix: Environment Variables' Apply never writes over a change it did not see, and a new variable is User or System - #2951

Merged
laurentiu021 merged 1 commit into
mainfrom
fix/environment-apply-keeps-outside-changes
Oct 22, 2026
Merged

laurentiu021 merged 1 commit into
mainfrom
fix/environment-apply-keeps-outside-changes

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

Apply on Environment Variables wrote the copy of a variable the tab had read when it opened, so a change made outside
the tab meanwhile was written over, and the new-variable picker offered "All".

What changed

  • Apply reads every variable it is about to change again. Python, Node.js, Git and JDK installers add themselves
    to PATH, and the tab stays open for as long as SysManager runs. Moving one PATH row and pressing Apply wrote back the
    PATH the tab had read, and the installer's folder was gone. After the confirmation, Apply now reads every variable
    it is about to write or delete again through the new EnvironmentVariableService.TryReadValue, raw as Read reads
    it, and applies nothing, the safety copy included, when one changed, a new one appeared under the same name, or one
    could not be read again. The status line names them, "PATH (User) was changed outside SysManager after this tab read
    it, so nothing was applied. Press Refresh to see the change, then make yours again.", and the edit stays pending.
  • A new variable is User or System. The "New variable scope" picker bound ScopeFilters, whose "All" made one
    User variable while the status line said "Added All variable 'X'". It binds NewScopes, User and System.
  • EnvVariable.LabelOf names a scope the way ScopeLabel does, for the variables Apply has only a scope and a name
    for.
  • CHANGELOG 1.130.58, README (Environment Variables), ARCHITECTURE (EnvironmentVariablesViewModel).

Tests

Over the redirected environment the other tests use, so no real variable is read or written:

  • An installer adds a folder to PATH after the tab read it, a PATH row is moved, and Apply leaves the registry's PATH
    as the installer left it, writes no safety copy, says why and keeps the edit pending. With nothing changed outside,
    the same Apply writes.
  • A new variable that appeared outside meanwhile, and a deleted one changed outside meanwhile, are left as they are.
  • The refusal's wording for one, two, three and more variables; TryReadValue reads a value raw and returns null for
    none; NewScopes is User and System and the view's picker binds it.

Each test failed against the defect it pins: with no check, with new variables or deletions left out of it, with the
value read expanded, and with the picker bound to the filter's list.

Closes #2798.

…ot see, and a new variable is User or System

- Apply compared each variable with the value the tab read when it opened and wrote the edited copy without reading
  the registry again, so a folder an installer added to PATH meanwhile was gone after the next PATH edit. After the
  confirmation, Apply now reads every variable it is about to write or delete again, through
  EnvironmentVariableService.TryReadValue, and applies nothing when one changed, a new one appeared under the same
  name, or one could not be read again. The status line names them and says to Refresh.
- The "New variable scope" picker listed the scope filter's choices, so "All" made one User variable and the status
  line said "Added All variable". It has its own list, User and System.
@laurentiu021
laurentiu021 merged commit 42359dc into main Oct 22, 2026
6 checks passed
@laurentiu021
laurentiu021 deleted the fix/environment-apply-keeps-outside-changes branch October 22, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant