Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PATH Environment Variable Corruption Issue (Fixed in Preview 3) #1599

Closed
andreww-msft opened this issue Oct 15, 2021 · 4 comments
Closed

PATH Environment Variable Corruption Issue (Fixed in Preview 3) #1599

andreww-msft opened this issue Oct 15, 2021 · 4 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@andreww-msft
Copy link
Contributor

andreww-msft commented Oct 15, 2021

This issue has been fixed in 1.0 Preview 3, released on 10/27!! If you've previously used 1.0 Preview 1 or Preview 2, you still must follow the steps below to fix your path.

The new EnvironmentManager API in 1.0 Preview 1 and Preview 2 of the Windows App SDK includes a mechanism to clean up any environment variable changes made by a packaged app when that app is uninstalled. This feature is in an experimental state, and the first release includes a known bug which can corrupt the system PATH environment variable.

This happens when the Undocked Deployment Extension Handler (DEH) executes, and this component executes whenever any packaged app is uninstalled, regardless of whether that app uses the Windows App SDK. The PATH is only corrupted if it contained the variable expansion character ‘%’.

Specifics:

The System PATH entry in the registry here:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path

…should be of type REG_EXPAND_SZ, but the DEH changes this to REG_SZ. This makes the PATH unusable if it contained the variable expansion character ‘%’.

Affected releases:

  • 1.0.0-preview1
  • 1.0.0-preview2

Mitigation:

To get your machine back into a good state, take the following steps:

  1. Check if the PATH in the registry is corrupt, and if so, reset it.
  2. Uninstall all apps that use the Windows App SDK 1.0 Preview1 or Preview2.
  3. Uninstall the Windows App SDK 1.0 Preview1/Preview2 packages, including the package that contains the DEH.

These steps can be accomplished with the following Windows PowerShell script (must use the latest version of Windows PowerShell, and run it elevated, don't use PowerShell Core):

# This script must be run from an elevated Windows PowerShell window (right-click Windows PowerShell in the Start menu, and select Run as Administrator).

# Remove the Windows App SDK 1.0 Preview1/2, and all apps that use it.

$winappsdk = "Microsoft.WindowsAppRuntime.1.0-preview*"
Get-AppxPackage | Where-Object { $_.Dependencies -like $winappsdk } | Remove-AppxPackage
Get-AppxPackage $winappsdk | Remove-AppxPackage


# If the PATH in the registry has been set to REG_SZ, delete it and recreate it as REG_EXPAND_SZ.

$EnvPath = 'Registry::HKLM\System\CurrentControlSet\Control\Session Manager\Environment'
$Environment=Get-Item $EnvPath
$PathKind = $Environment.GetValueKind('Path')

if ($PathKind -ne 'ExpandString') {
  $Path = $Environment.GetValue('Path')
  Remove-ItemProperty $EnvPath -Name Path
  New-ItemProperty $EnvPath -Name Path -PropertyType ExpandString -Value $Path
}

Fix:

The EnvironmentManager functionality in the Undocked DEH component will be removed in the upcoming Release 1.0 Preview 3. This functionality may be reintroduced at a later date, when all bugs have been fixed and thoroughly tested.

@ghost ghost added the needs-triage label Oct 15, 2021
@andreww-msft andreww-msft self-assigned this Oct 15, 2021
@asklar asklar pinned this issue Oct 15, 2021
@andrewleader andrewleader added bug Something isn't working and removed needs-triage labels Oct 15, 2021
@kmgallahan
Copy link

So as long as you don't uninstall any packaged app on the system the bug shouldn't trigger?

Do any packaged apps ever get uninstalled by Visual Studio automatically while developing packaged apps?

Trying to balance productivity of downgrading vs. just being careful. Is Preview 3 coming relatively soon™?

@ParkhutRoman
Copy link

It's not like windows will start crashing with corrupted PATH environment variables(I didn't even notice it for 2 months). For me the way out of this is open PowerShell window with given above 2 part of script, and runing it after work, it is too tedious for me to roll back to 0.8.5

@stevewhims
Copy link
Member

Also see Important issue impacting 1.0 Preview 1 and Preview 2 on docs.microsoft.com.

@andrewleader andrewleader changed the title PATH Environment Variable Corruption Issue PATH Environment Variable Corruption Issue (Fixed in Preview 3) Oct 27, 2021
@andrewleader
Copy link
Contributor

This issue has been fixed in 1.0 Preview 3, released today!! If you've previously used 1.0 Preview 1 or Preview 2, you still must follow the steps above to fix your path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants