KEMBAR78
Fix portable path removal on upgrade by dkbennett · Pull Request #5756 · microsoft/winget-cli · GitHub
Skip to content

Conversation

dkbennett
Copy link
Member

@dkbennett dkbennett commented Sep 29, 2025

Closes #4044
Closes #3616

The path is being lost under the condition of Dev Mode being disabled with a user install, because we only set the PATH if symlinks are not available. In this situation, the portable package is registered with a path set, and that information is added to the ARP entry. When an upgrade occurs, this path being set value is true and when removing the old version we are also removing the path since it was set. Then when we add the new version, the variable that says the path was set is still true, so it does not re-add the path and does not set the path information in the ARP entry.

The fix is to update the variable that indicates the path has been set whenever we remove the path. This causes the install of the new version to recognize that the path has been removed and to re-enable it (and then re-set the variable). This is a targeted fix that only affects the PATH setting

Repro steps for this issue:

  1. Disable dev mode (it does not repro with dev mode enabled)
  2. Install old version of package
  3. Open a new command window and verify path is correctly set and program launches.
  4. Upgrade to latest version of package
  5. Open a command window and verify that the path is now gone.

With the fix step 5 is the same result as step 3.

Tested:

  • Verified with terragrunt and pnpm are confirmed fixed.
  • Tested with and without the fix to confirm the fix addresses the issue.
  • Verified in debugger the code path expected is hit.

Microsoft Reviewers: Open in CodeFlow

@microsoft-github-policy-service microsoft-github-policy-service bot added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Sep 29, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Area-Path Issue related to path environment variable label Sep 29, 2025
@dkbennett dkbennett merged commit 50adeab into microsoft:master Sep 29, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Path Issue related to path environment variable Issue-Bug It either shouldn't be doing this or needs an investigation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Portable packages installed in user scope are removed from PATH after upgrading them pnpm missing from path after updating

2 participants