Skip to content

fix(install): skip Microsoft Store python.exe stub in Test-Python fallback (#24424) - #24543

Closed
briandevans wants to merge 2 commits into
NousResearch:mainfrom
briandevans:fix/install-ps1-store-stub-24424
Closed

fix(install): skip Microsoft Store python.exe stub in Test-Python fallback (#24424)#24543
briandevans wants to merge 2 commits into
NousResearch:mainfrom
briandevans:fix/install-ps1-store-stub-24424

Conversation

@briandevans

Copy link
Copy Markdown
Contributor

Summary

  • Fresh Windows 11 installs of Hermes fail at the python-detection step because the installer invokes the Microsoft Store app-execution alias at %LOCALAPPDATA%\Microsoft\WindowsApps\python.exe, which isn't a real interpreter.
  • The stub's "Python was not found..." message bubbles up through $ErrorActionPreference = 'Stop' and replaces the script's friendlier error.
  • Fix: detect the alias by path, skip it in the fallback, and surface a one-line pointer to the Windows toggle when it's the only python.exe on PATH.

The bug

scripts/install.ps1 runs Test-Python with three fallback layers:

  1. uv python find 3.11
  2. uv python install 3.11 then re-find
  3. uv python find 3.12 / 3.13 / 3.10
  4. System-Python fallbackGet-Command python then python --version

On a clean Windows 11, layer 4 picks up the Store app-execution alias, 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. With $ErrorActionPreference = 'Stop' set at the top of the script, the NativeCommandError replaces the script's own throw, surfacing to the user as

✗ Installation failed: Python was not found...

The reporter's transcript in #24424 shows this exact sequence — uv python install 3.11 failed with a flaky download, the secondary uv python find for 3.10/3.12/3.13 also found nothing, and the bare python fallback hit the Store stub.

The fix

In Test-Python (scripts/install.ps1):

  • Capture Get-Command python -ErrorAction SilentlyContinue into $pythonCmd.
  • Skip when $pythonCmd.Source -match '\WindowsApps\' — that's the Store alias directory.
  • Invoke & $pythonCmd.Source --version via the resolved path inside a try/catch so a broken interpreter can't terminate the script through Stop preference.
  • When the alias is the only python.exe on 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.exe on PATH — the regex '\\WindowsApps\\' only matches the Store alias's install path.

Test plan

  • Focused regression test: tests/tools/test_windows_native_support.py::TestInstallPs1SkipsStorePythonStub — source-level lint that the install.ps1 contains the WindowsApps skip guard and invokes $pythonCmd.Source --version rather than bare python. Runs on Linux CI; no Windows runner needed.
  • Adjacent suite: full tests/tools/test_windows_native_support.py (60 tests) passes locally — no collateral damage to the existing source-level lints.
  • Regression guard: the new tests assert presence of strings only introduced in this PR ("WindowsApps", "$pythonCmd.Source --version"); reverting scripts/install.ps1 causes both assertions to fail with the precise scope they're meant to protect.

Related

Copilot AI review requested due to automatic review settings May 12, 2026 21:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-Python in scripts/install.ps1 to resolve python via Get-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 thread scripts/install.ps1
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)."
)
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels May 12, 2026
@briandevans

Copy link
Copy Markdown
Contributor Author

@copilot All findings addressed in commit 0dd36e5:

  • scripts/install.ps1 — narrowed the alias guard from -notmatch '\WindowsApps\' to -notmatch '\Microsoft\WindowsApps\' on both the skip branch and the hint branch, so a legitimate python.exe that happens to live under any other WindowsApps directory is no longer also skipped.
  • tests/tools/test_windows_native_support.py — replaced the bare "WindowsApps" in source substring assertion with a guard-expression assertion ($pythonCmd.Source -notmatch '\Microsoft\WindowsApps\') so a regression that removes the actual check (leaving only the comment) fails loudly. Added a parallel test for the match-branch hint.

briandevans and others added 2 commits May 14, 2026 02:11
…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
briandevans force-pushed the fix/install-ps1-store-stub-24424 branch from 0dd36e5 to 163dcaf Compare May 14, 2026 09:11
@briandevans

Copy link
Copy Markdown
Contributor Author

Closing — superseded by @teknium1's #26586 which landed on main (commit 622c27e) and covers the same Microsoft Store stub skip in install.ps1's Test-Python fallback. Happy to reopen if there's a remaining gap I missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Windows native installation fails if python not installed

3 participants