play.ps1: find victory.exe on Windows PowerShell 5.1 #17
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Zettrox/ztrx. Originally posted by 0xkn0wh3r3 on 2026-11-25T02:59:44Z.
Problem
scripts\play.ps1sets its-Exedefault from$PSScriptRootin theparam()block. Windows PowerShell 5.1 (thepowershellthe README's command runs) leaves$PSScriptRootempty in the parameter defaults of a script with[Parameter()]attributes, whichplay.ps1has. The default becomes\..\target\release\victory.exeand the launch fails:Fix
-Exewithout a default inparam()and compute it in the script body from$PSScriptRoot, which is set there on 5.1 and 7.-Exeonce and launch exactly what was found:PATHwithGet-Command -CommandType Application, as& $Exedoes.-Exe), stop with a clear message and exit 1 before launching.Explicit paths and
PATHnames launch the same executable as before; the difference is that a missing one is reported up front.Exit-code propagation (#3) is left to #15, which changes only the last lines of the script; the two merge cleanly.
Tested
A stub executable in place of
victory.exe, run from a working directory outside the repository, with the repository copy at a path containing spaces and brackets and a game path containing spaces and brackets. Same results on Windows PowerShell 5.1 and PowerShell 7.6:PATH(with and without.exe)PATH-ExeWhen the child ran, it received the game path as one argument and both output streams reached the log. The same matrix on this branch merged with #15 passes, with exit codes 7 and 42 returned to the caller.
cargo xtask policy --stagedpasses.Imported from Zettrox/ztrx. Originally posted by Yoshi-233 on 2026-11-25T03:03:25Z.
I tested how this interacts with #15, since both change
play.ps1. Git merged1d1ffaa(#17) andafe450a(#15) cleanly on90b529f. I ran 12 process-level cases on #17 alone, then the same 12 on the combined script, using PowerShell 7.7.0 on Ubuntu and a small native executable. The working directory was outside the project.-Exeall returned 1 before the child ran.This covers the interaction between locating the executable and returning its status. The Windows PowerShell 5.1 check is the author's; my runs used PowerShell 7.
Imported from Zettrox/ztrx. Originally posted by kaayzouee on 2026-11-25T03:19:12Z.
Code review — Changes recommended
Reviewed commit 0971fd8. Moving default executable discovery out of the parameter block is a reasonable fix for Windows PowerShell 5.1. However, the new existence check introduces a compatibility regression.
Previously, & $Exe could resolve a bare executable name through PATH. The new Test-Path -LiteralPath $Exe -PathType Leaf rejects such a name when the executable is not in the current directory.
Conversely, a bare filename can pass the existence check but fail to launch or resolve to a different executable on PATH.
Please resolve and invoke the same executable. If explicit paths are required, resolve them to filesystem paths before invocation and document that requirement. If preserving PATH lookup, resolve bare names using Get-Command with -CommandType Application and invoke the resolved application path.
The script still prints $LASTEXITCODE without returning it to the caller.
This is the existing issue #3, not a regression introduced by this PR. Consider capturing the child’s exit code immediately after execution, reporting it, and ending with exit $code. Launch failures should also be handled explicitly rather than relying on a potentially stale $LASTEXITCODE.
This can be addressed separately if keeping the PR narrowly scoped.
The default executable path can be computed directly in the script body without the additional Split-Path call:
if (-not $Exe) {
$Exe = Join-Path $PSScriptRoot '..\target\release\victory.exe'
}
The PowerShell 5.1 issue concerns parameter default evaluation, not $PSScriptRoot inside the script body.
A controlled executable stub is sufficient; no game data is necessary.
Verdict
The default-path fix is small, readable, and appropriately scoped. However, I recommend correcting the explicit -Exe resolution regression before merging, particularly because the PR states that explicitly supplied values behave as before.
Static review only. Windows PowerShell tests were not independently executed.
⸻
This is an automated message, if you believe this is incorrect, please reply with the relevant technical context or a reproducible counterexample so the finding can be reassessed.
Imported from Zettrox/ztrx. Originally posted by 0xkn0wh3r3 on 2026-11-25T03:39:06Z.
Thanks to both of you. Changes are in
6657725:-Exeresolution: fixed.-Exeis resolved once and that exact file is launched. A path must be an existing file and is made absolute. A bare name is looked up withGet-Command -CommandType Application, matching what& $Exefinds onPATH. A bare name sitting only in the current directory is no longer accepted, because&would not run it from there either.$PSScriptRootin the body: done, and the root cause is now stated more precisely. On 5.1 it's empty only in the parameter defaults of a script with[Parameter()]attributes. A plainparam()script gets it, and the body always does.@Yoshi-233, your PowerShell 7 results agree with mine. The 5.1 rows in the table are from a Windows machine.
Imported from Zettrox/ztrx. Originally posted by whamre on 2026-11-25T09:00:35Z.
Tested on Windows PowerShell 5.1 with an RTX 2080 SUPER. On main,
play.ps1fails withThe term '\..\target\release\victory.exe' is not recognized, because$PSScriptRootis empty in the param default. With this PR (built together with #32 and #68 on90b529f), the launcher found and startedtarget\release\victory.exewith no-Exeargument. AI-assisted.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.