fix(install): skip Microsoft Store python.exe stub in Test-Python fallback (#24424) - #24543
Closed
briandevans wants to merge 2 commits into
Closed
fix(install): skip Microsoft Store python.exe stub in Test-Python fallback (#24424)#24543briandevans wants to merge 2 commits into
briandevans wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the Windows PowerShell installer’s Python detection by avoiding the Microsoft Store python.exe app-execution alias (the %LOCALAPPDATA%\Microsoft\WindowsApps\python.exe stub) so fresh Windows 11 installs don’t fail with the stub’s “Python was not found…” message overriding the installer’s own error handling.
Changes:
- Updates
Test-Pythoninscripts/install.ps1to resolvepythonviaGet-Command, skip the WindowsApps alias, and invoke the resolved command path inside try/catch. - Adds a targeted source-level regression test to ensure the WindowsApps guard and resolved-path invocation remain present.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
scripts/install.ps1 |
Adds WindowsApps alias detection/skip and safer resolved-path invocation for python --version, plus clearer guidance when only the alias is present. |
tests/tools/test_windows_native_support.py |
Adds a regression test that lints install.ps1 source for the WindowsApps guard and resolved-path invocation marker. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+186
to
+188
| $pythonCmd = Get-Command python -ErrorAction SilentlyContinue | ||
| if ($pythonCmd -and ($pythonCmd.Source -notmatch '\\WindowsApps\\')) { | ||
| try { |
Comment on lines
+489
to
+497
| # The fallback that calls `Get-Command python` must check the resolved | ||
| # Source path against `\WindowsApps\` and skip the alias rather than | ||
| # invoking it. | ||
| assert "WindowsApps" in source, ( | ||
| "scripts/install.ps1 must detect the Microsoft Store python.exe " | ||
| "app-execution alias (under %LOCALAPPDATA%\\Microsoft\\WindowsApps\\) " | ||
| "and skip invoking it — otherwise a fresh Windows 11 install fails " | ||
| "with the stub's 'Python was not found' message (see #24424)." | ||
| ) |
Contributor
Author
|
@copilot All findings addressed in commit 0dd36e5:
|
…lback (NousResearch#24424) On fresh Windows 11, `Get-Command python` returns the Microsoft Store app-execution alias at `%LOCALAPPDATA%\Microsoft\WindowsApps\python.exe` even when no real Python is installed. The Test-Python fallback in scripts/install.ps1 invoked that stub, which prints "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases" and exits non-zero. Because install.ps1 sets `$ErrorActionPreference = "Stop"`, that surfaces as the terminating error `✗ Installation failed: Python was not found...` — exactly the symptom reported in NousResearch#24424. Fix the fallback to: 1. Skip the alias by matching the resolved `Get-Command` Source against `\WindowsApps\`. 2. Invoke `--version` via the resolved Source path inside a try/catch so a NativeCommandError from a broken interpreter doesn't kill the script outright. 3. When the stub is the only `python.exe` on PATH, tell the user where the Windows toggle lives so they don't have to search for it. Added two source-level regression tests in `tests/tools/test_windows_native_support.py` (no Windows runner needed) that lint the install.ps1 for the WindowsApps guard and the resolved-Source invocation pattern. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… bind test to guard expression Addresses Copilot review feedback on NousResearch#24543: 1. The `-notmatch '\WindowsApps\'` check was broader than the intent — any legitimate `python.exe` that happens to live under any `WindowsApps` directory would also be skipped. The Microsoft Store app-execution alias for python.exe lives specifically at `%LOCALAPPDATA%\Microsoft\WindowsApps\python.exe`, so narrow the regex to `\Microsoft\WindowsApps\` on both the skip and hint branches. 2. The regression test asserted only that the literal string "WindowsApps" appeared somewhere in the source. That would still pass if the guard were removed and only the explanatory comment remained. Bind the test to the exact guard expression (`Source -notmatch '\Microsoft\WindowsApps\'`) and add a parallel test for the failure-branch hint (`Source -match '\Microsoft\WindowsApps\'`), so a regression that removes either branch fails loudly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
briandevans
force-pushed
the
fix/install-ps1-store-stub-24424
branch
from
May 14, 2026 09:11
0dd36e5 to
163dcaf
Compare
Contributor
Author
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.
Summary
%LOCALAPPDATA%\Microsoft\WindowsApps\python.exe, which isn't a real interpreter.$ErrorActionPreference = 'Stop'and replaces the script's friendlier error.python.exeon PATH.The bug
scripts/install.ps1runsTest-Pythonwith three fallback layers:uv python find 3.11uv python install 3.11then re-finduv python find 3.12 / 3.13 / 3.10Get-Command pythonthenpython --versionOn a clean Windows 11, layer 4 picks up the Store app-execution alias, which prints
and exits non-zero. With
$ErrorActionPreference = 'Stop'set at the top of the script, the NativeCommandError replaces the script's own throw, surfacing to the user asThe reporter's transcript in #24424 shows this exact sequence —
uv python install 3.11failed with a flaky download, the secondaryuv python findfor 3.10/3.12/3.13 also found nothing, and the barepythonfallback hit the Store stub.The fix
In
Test-Python(scripts/install.ps1):Get-Command python -ErrorAction SilentlyContinueinto$pythonCmd.$pythonCmd.Source -match '\WindowsApps\'— that's the Store alias directory.& $pythonCmd.Source --versionvia the resolved path inside a try/catch so a broken interpreter can't terminate the script throughStoppreference.python.exeon PATH, add a short pointer to the toggle location (Settings > Apps > Advanced app settings > App execution aliases) before the existing "install Python 3.11 manually" guidance, so the user doesn't have to copy the path out of the error message and search for it.No behavior change when the user has a real
python.exeon PATH — the regex'\\WindowsApps\\'only matches the Store alias's install path.Test plan
tests/tools/test_windows_native_support.py::TestInstallPs1SkipsStorePythonStub— source-level lint that the install.ps1 contains theWindowsAppsskip guard and invokes$pythonCmd.Source --versionrather than barepython. Runs on Linux CI; no Windows runner needed.tests/tools/test_windows_native_support.py(60 tests) passes locally — no collateral damage to the existing source-level lints."WindowsApps","$pythonCmd.Source --version"); revertingscripts/install.ps1causes both assertions to fail with the precise scope they're meant to protect.Related