fix(launcher): keep PowerShell 5.1 stderr redirection from aborting on native warnings (#233) #236

Manually merged
github merged 1 commit from gh-pr/236/head into gh-pr/236/base 2026-11-26 05:39:14 +00:00
Owner

@⁠Lewandox on GitHub · 2026-11-25 20:41 UTC · original
Lewandox:fix/launcher-ps51-stderr → main · +95 −4 · 2 files · 1 commits · merged 2026-11-25 21:45 UTC

Summary

Fixes #233.

Under Windows PowerShell 5.1, redirecting stderr (.\tools\lancer_victory.ps1 -GameDir ... 2> victory.log) wraps every stderr line from native executables in a NativeCommandError ErrorRecord. Because tools/lancer_victory.ps1 sets $ErrorActionPreference = 'Stop', any benign stderr output (such as a cargo deprecation warning) terminates the launcher before victory.exe ever starts.

This wraps the three native invocations (cargo build, $exe translate, and $exe run) in a try/finally block that temporarily sets $ErrorActionPreference = 'Continue' while keeping $ErrorActionPreference = 'Stop' for all PowerShell cmdlets/validation, preserving stderr redirection (2> victory.log), and still failing fast on any non-zero $LASTEXITCODE.

Tests

  • Added test_launcher_survives_stderr_redirection_in_windows_powershell_51 in tests/test_lanceur_victory.py:
    • Before fix: reproduced #233 under Windows PowerShell 5.1 (powershell.exe -Command "& '...lancer_victory.ps1' -GameDir '...' 2> '...victory.log'") — failed on NativeCommandError at cargo build and never ran victory.exe.
    • After fix: cargo and victory both run to completion, exit code is preserved (7), and both stderr lines land in victory.log.
  • Verified .venv\Scripts\python.exe -m pytest tests/test_lanceur_victory.py -vv: 15 passed, 0 failed.
  • Verified test_launcher_stops_when_the_build_fails still fails cleanly when cargo exits non-zero (101).

Overlap note

Open PR #234 also touches tools/lancer_victory.ps1 and tests/test_lanceur_victory.py (adding -Fast switches), in separate regions from the native invocations touched here.

**@⁠Lewandox** on GitHub · 2026-11-25 20:41 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/236) `Lewandox:fix/launcher-ps51-stderr` → `main` · +95 −4 · 2 files · 1 commits · merged 2026-11-25 21:45 UTC ## Summary Fixes #233. Under Windows PowerShell 5.1, redirecting stderr (`.\tools\lancer_victory.ps1 -GameDir ... 2> victory.log`) wraps every stderr line from native executables in a `NativeCommandError` `ErrorRecord`. Because `tools/lancer_victory.ps1` sets `$ErrorActionPreference = 'Stop'`, any benign stderr output (such as a `cargo` deprecation warning) terminates the launcher before `victory.exe` ever starts. This wraps the three native invocations (`cargo build`, `$exe translate`, and `$exe run`) in a `try`/`finally` block that temporarily sets `$ErrorActionPreference = 'Continue'` while keeping `$ErrorActionPreference = 'Stop'` for all PowerShell cmdlets/validation, preserving stderr redirection (`2> victory.log`), and still failing fast on any non-zero `$LASTEXITCODE`. ## Tests - Added `test_launcher_survives_stderr_redirection_in_windows_powershell_51` in `tests/test_lanceur_victory.py`: - **Before fix:** reproduced #233 under Windows PowerShell 5.1 (`powershell.exe -Command "& '...lancer_victory.ps1' -GameDir '...' 2> '...victory.log'"`) — failed on `NativeCommandError` at `cargo build` and never ran `victory.exe`. - **After fix:** `cargo` and `victory` both run to completion, exit code is preserved (`7`), and both stderr lines land in `victory.log`. - Verified `.venv\Scripts\python.exe -m pytest tests/test_lanceur_victory.py -vv`: **15 passed, 0 failed**. - Verified `test_launcher_stops_when_the_build_fails` still fails cleanly when `cargo` exits non-zero (`101`). ## Overlap note Open PR #234 also touches `tools/lancer_victory.ps1` and `tests/test_lanceur_victory.py` (adding `-Fast` switches), in separate regions from the native invocations touched here.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:39:12 +00:00
github manually merged commit c8eb54ae5a into gh-pr/236/base 2026-11-26 05:39:14 +00:00
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-25 21:03 UTC · original

Thanks, the fix is right for the launcher as it was. Note that #243 (just merged) rewrote tools/lancer_victory.ps1 on the Neptune base: it still sets $ErrorActionPreference = 'Stop' and calls cargo build, victory warm (twice) and victory run without your wrapper, so this PR now conflicts and the stderr problem is back on those calls. Could you re-port the wrapper onto those native calls of the new launcher and add your stderr test to the current tests/test_lanceur_victory.py?

**@⁠LooperSalty** on GitHub · 2026-11-25 21:03 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/236#issuecomment-7174545652) Thanks, the fix is right for the launcher as it was. Note that #243 (just merged) rewrote `tools/lancer_victory.ps1` on the Neptune base: it still sets `$ErrorActionPreference = 'Stop'` and calls cargo build, `victory warm` (twice) and `victory run` without your wrapper, so this PR now conflicts and the stderr problem is back on those calls. Could you re-port the wrapper onto those native calls of the new launcher and add your stderr test to the current `tests/test_lanceur_victory.py`?
Author
Owner

@⁠Lewandox on GitHub · 2026-11-25 21:08 UTC · original

Re-ported onto the new Neptune launcher (93e0b79) across all four native invocations (cargo build, both victory warm calls in -Warm and -Precompile, and victory run), and updated test_launcher_survives_stderr_redirection_in_windows_powershell_51 in tests/test_lanceur_victory.py to exercise both the default run path and -Warm -Precompile under Windows PowerShell 5.1 2> redirection.

Verified locally: pytest tests/test_lanceur_victory.py -vv -> 19 passed, 0 failed.

**@⁠Lewandox** on GitHub · 2026-11-25 21:08 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/236#issuecomment-7174671711) Re-ported onto the new Neptune launcher (`93e0b79`) across all four native invocations (`cargo build`, both `victory warm` calls in `-Warm` and `-Precompile`, and `victory run`), and updated `test_launcher_survives_stderr_redirection_in_windows_powershell_51` in `tests/test_lanceur_victory.py` to exercise both the default run path and `-Warm -Precompile` under Windows PowerShell 5.1 `2>` redirection. Verified locally: `pytest tests/test_lanceur_victory.py -vv` -> **19 passed, 0 failed**.
This discussion has been locked. Commenting is limited to contributors.
No description provided.