[MXC] Add checks and fixes for Python and App Execution Aliases#326
Merged
Conversation
…E2E tests E2E tests failed with cryptic errors (exit 9009, CreateProcessW 0x80070057) when Python was missing/per-user or Windows Store App Execution Aliases shadowed real executables. Store reparse points cannot be launched inside AppContainer/BaseContainer sandboxes. Changes: - build.bat: add post-build prereq warnings with interactive fix (install Python via winget + remove Store aliases) when running elevated - build.rs (wxc): emit cargo:warning during compilation when Python/pwsh are missing or resolve to Store aliases - wxc_e2e_tests: add assert_python()/assert_pwsh() that fail tests with clear remediation messages instead of cryptic exit codes - test_configs/basic_lpac.json: fix import sys being inside print() string - test_configs/pwsh_setlocation.json: use full path for pwsh.exe, remove hardcoded C:\Users\st path - scripts/setup-test-prereqs.ps1: standalone elevated setup script Closes #323 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- build.bat: only warn when ALL python/pwsh matches are Store aliases (no false positive when real install coexists); remove duplicate ALIAS_ISSUE assignment; apply same logic to pwsh check - build.rs: add cargo:rerun-if-env-changed=PATH so warnings update after installing Python/PowerShell - lib.rs: use case-insensitive check (to_ascii_lowercase) for WindowsApps detection in assert_python() and assert_pwsh() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- assert_python: fail when *first* PATH match is a Store alias (shadowing), not just when all matches are aliases — matches actual sandbox behavior - assert_pwsh: validate hardcoded C:\Program Files\PowerShell\7\pwsh.exe path exists instead of generic where.exe check - build.bat: detect first-match Store alias shadowing for python.exe; simplified pwsh check to validate expected install path - setup-test-prereqs.ps1: use Get-Command -All to find any real Python even when Store alias shadows it; check \0 after winget install; handle missing winget gracefully Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines
+150
to
+156
| if "!PYTHON_FIRST_ALIAS!"=="1" ( | ||
| echo WARNING: python.exe first resolves to a Store alias. | ||
| echo Store aliases shadow real installs and cannot be launched inside sandbox containers. | ||
| set "PREREQ_WARN=1" | ||
| set "PYTHON_MISSING=1" | ||
| set "ALIAS_ISSUE=1" | ||
| ) |
Comment on lines
+181
to
+200
| set /p "FIX_ALL= Fix issues and install Python? [Y/n] " | ||
| if /i "!FIX_ALL!"=="n" goto :done | ||
|
|
||
| if "%PYTHON_MISSING%"=="1" ( | ||
| echo Installing Python 3.12 via winget... | ||
| winget install Python.Python.3.12 --scope machine --accept-package-agreements --accept-source-agreements | ||
| ) | ||
|
|
||
| if "%ALIAS_ISSUE%"=="1" ( | ||
| echo Removing Store aliases... | ||
| if exist "%LOCALAPPDATA%\Microsoft\WindowsApps\python.exe" del /f "%LOCALAPPDATA%\Microsoft\WindowsApps\python.exe" 2>nul && echo Removed python.exe alias | ||
| if exist "%LOCALAPPDATA%\Microsoft\WindowsApps\python3.exe" del /f "%LOCALAPPDATA%\Microsoft\WindowsApps\python3.exe" 2>nul && echo Removed python3.exe alias | ||
| if exist "%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe" del /f "%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe" 2>nul && echo Removed pwsh.exe alias | ||
| ) | ||
|
|
||
| echo. | ||
| echo Prerequisites fixed. Starting a fresh terminal to pick up PATH changes... | ||
| echo. | ||
| start cmd /k "cd /d %~dp0 && echo Ready. Run your tests now." | ||
|
|
Comment on lines
+58
to
+86
| // Check pwsh | ||
| let pwsh_ok = Command::new("where.exe") | ||
| .arg("pwsh.exe") | ||
| .output() | ||
| .ok() | ||
| .and_then(|o| { | ||
| if !o.status.success() { | ||
| return None; | ||
| } | ||
| let stdout = String::from_utf8_lossy(&o.stdout).to_string(); | ||
| let first = stdout.lines().next().unwrap_or("").to_string(); | ||
| Some(first) | ||
| }); | ||
|
|
||
| match pwsh_ok { | ||
| None => { | ||
| println!("cargo:warning=pwsh.exe not found. PowerShell 7 sandbox tests will fail."); | ||
| println!( | ||
| "cargo:warning=Fix: Run scripts\\setup-test-prereqs.ps1 (elevated) or install PowerShell 7" | ||
| ); | ||
| } | ||
| Some(ref path) if path.to_ascii_lowercase().contains("windowsapps") => { | ||
| println!("cargo:warning=pwsh.exe resolves to a Store alias. Store aliases cannot be launched inside sandbox containers."); | ||
| println!( | ||
| "cargo:warning=Fix: Run scripts\\setup-test-prereqs.ps1 (elevated) or disable App Execution Aliases for PowerShell" | ||
| ); | ||
| } | ||
| _ => {} | ||
| } |
Comment on lines
+125
to
+132
| $pwshReal = Get-Command pwsh.exe -All -ErrorAction SilentlyContinue | | ||
| Where-Object { $_.Source -notlike "*WindowsApps*" } | | ||
| Select-Object -First 1 | ||
| if ($pwshReal) { | ||
| Write-Host " OK ($($pwshReal.Source))" -ForegroundColor Green | ||
| } else { | ||
| Write-Host " MISSING (no non-Store pwsh.exe found)" -ForegroundColor Red | ||
| $issues += "PowerShell 7 is not installed (or only available via Store alias)." |
Comment on lines
+220
to
+257
| /// Check whether `python.exe` is available and the *first* match in PATH | ||
| /// is NOT a Windows Store App Execution Alias. Store aliases are reparse | ||
| /// points under `WindowsApps` that cannot be launched inside | ||
| /// AppContainer/BaseContainer sandboxes. Even when a real Python exists | ||
| /// later in PATH, the sandbox will try to launch the first match and fail. | ||
| /// | ||
| /// Panics with a clear remediation message when Python is missing or | ||
| /// the first PATH match is a Store alias. | ||
| pub fn assert_python() { | ||
| let output = Command::new("where.exe").arg("python.exe").output().ok(); | ||
|
|
||
| let Some(output) = output else { | ||
| panic!( | ||
| "python.exe not found.\n\ | ||
| E2E tests require a system-wide Python install.\n\ | ||
| Fix: Run scripts\\setup-test-prereqs.ps1 (elevated) or install Python system-wide \ | ||
| (winget install Python.Python.3.12 --scope machine)" | ||
| ); | ||
| }; | ||
|
|
||
| if !output.status.success() { | ||
| panic!( | ||
| "python.exe not found.\n\ | ||
| E2E tests require a system-wide Python install.\n\ | ||
| Fix: Run scripts\\setup-test-prereqs.ps1 (elevated) or install Python system-wide \ | ||
| (winget install Python.Python.3.12 --scope machine)" | ||
| ); | ||
| } | ||
|
|
||
| let stdout = String::from_utf8_lossy(&output.stdout); | ||
| let first_path = stdout.lines().next().unwrap_or(""); | ||
| if first_path.to_ascii_lowercase().contains("windowsapps") { | ||
| panic!( | ||
| "python.exe first resolves to a Windows Store alias ({first_path}).\n\ | ||
| Store aliases shadow real installs and cannot be launched inside sandbox containers.\n\ | ||
| Fix: Run scripts\\setup-test-prereqs.ps1 (elevated) or disable App Execution Aliases for Python" | ||
| ); | ||
| } |
| $userAlias = Join-Path $env:LOCALAPPDATA "Microsoft\WindowsApps\$ExeName" | ||
| if (Test-Path $userAlias) { | ||
| Remove-Item $userAlias -Force -ErrorAction SilentlyContinue | ||
| Write-Host " Disabled user alias: $userAlias" -ForegroundColor Green |
- build.bat: check winget exists before invoking; report if install fails - build.rs: check pwsh at hardcoded C:\Program Files\PowerShell\7\pwsh.exe instead of where.exe (matches test config and assert_pwsh) - setup-test-prereqs.ps1: check pwsh at expected install path instead of Get-Command PATH lookup (consistent with test config) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jsidewhite
reviewed
May 18, 2026
jsidewhite
reviewed
May 18, 2026
| # Removing them from the user-local path disables the alias for the current user. | ||
| $userAlias = Join-Path $env:LOCALAPPDATA "Microsoft\WindowsApps\$ExeName" | ||
| if (Test-Path $userAlias) { | ||
| Remove-Item $userAlias -Force -ErrorAction SilentlyContinue |
Member
jsidewhite
reviewed
May 18, 2026
…Test-StoreAlias Per Jeff's feedback (PR #326): - build.bat: remove all interactive fix logic (winget install, alias removal, terminal restart). build.bat is for dev machines; nuking aliases there is inappropriate. It now just emits warnings + a pointer to scripts\setup-test-prereqs.ps1 for test machines. - setup-test-prereqs.ps1: simplify Test-StoreAlias to just check %LOCALAPPDATA%\Microsoft\WindowsApps\<exe> (the redundant AppData subset clause is gone). Disable-StoreAlias now documents that: 1. This is intended for TEST MACHINES ONLY. 2. Deleting the reparse point IS the Windows-documented mechanism to disable an alias (per AppAliasListItemSetting::SetValue in onecore/base/appmodel/AppExecutionAlias/settingshandlers). 3. Updates may restore aliases. Verified via Windows OS source (Os.2020 br_current). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jsidewhite
reviewed
May 19, 2026
| for /f "tokens=*" %%P in ('where python.exe') do ( | ||
| echo %%P | findstr /i "WindowsApps" >nul 2>&1 | ||
| if not errorlevel 1 ( | ||
| echo WARNING: python.exe first resolves to a Store alias. |
Member
jsidewhite
reviewed
May 19, 2026
| echo All E2E test prerequisites met. | ||
| ) else ( | ||
| echo. | ||
| echo To fix, run from an elevated PowerShell prompt: |
Member
jsidewhite
reviewed
May 19, 2026
| echo All E2E test prerequisites met. | ||
| ) else ( | ||
| echo. | ||
| echo To fix, run from an elevated PowerShell prompt: |
jsidewhite
reviewed
May 19, 2026
| Remove-Item $userAlias -Force -ErrorAction Stop | ||
| Write-Host " Disabled user alias: $userAlias" -ForegroundColor Green | ||
| } catch { | ||
| Write-Host " WARNING: failed to remove $userAlias`: $($_.Exception.Message)" -ForegroundColor Yellow |
jsidewhite
reviewed
May 19, 2026
| # Fix: Disable Store aliases | ||
| foreach ($exe in @("python.exe", "python3.exe", "pwsh.exe")) { | ||
| if (Test-StoreAlias $exe) { | ||
| Write-Host "Disabling Store alias for $exe..." -ForegroundColor Cyan |
Member
- build.bat: check the exact App Execution Alias reparse point path (%LOCALAPPDATA%\Microsoft\WindowsApps\python.exe) instead of any substring containing 'WindowsApps'. Reword 'fix' -> 'install Python and disable the alias'. - setup-test-prereqs.ps1: rename Test-StoreAlias/Disable-StoreAlias to Test-AppExecutionAlias/Disable-AppExecutionAlias. Replace all 'Store alias' wording with 'App Execution Alias'. Use Write-Warning instead of Write-Host for warnings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
E2E tests failed with cryptic errors (exit
9009,CreateProcessW 0x80070057) when Python was missing/per-user or Windows Store App Execution Aliases shadowed real executables. Store reparse points cannot be launched inside AppContainer/BaseContainer sandboxes.Changes:
build.bat: post-build prereq warnings with interactive fix (install Python via winget + remove Store aliases) when running elevated; opens a fresh terminal after fix for PATH to take effectsrc/wxc/build.rs: emitcargo:warningduring compilation when Python/pwsh are missing or resolve to Store aliasessrc/wxc_e2e_tests:assert_python()/assert_pwsh()fail tests with clear remediation messages instead of cryptic exit codes; checks if any non-Store path exists (not just the first)test_configs/basic_lpac.json: fiximport sysbeing insideprint()string literaltest_configs/pwsh_setlocation.json: use full path for pwsh.exe, remove hardcodedC:\Users\stpathscripts/setup-test-prereqs.ps1: standalone elevated setup script for one-time machine setupReferences
Closes #323
Validation
cargo buildbuild.batdetects missing Python/Store aliases, prompts to fix when elevated, opens fresh terminalpwsh_setlocationpasses with full path in configChecklist
Issue Type
Microsoft Reviewers: Open in CodeFlow