fix(install): version pinning defeated on PS 5.1, and TEMP cleanup leaks on spaced profiles - #354
Open
unlimitedmediagroup wants to merge 1 commit into
Conversation
…rofiles Two Windows installer bugs, both silent. 1. Resolve-Version always failed on Windows PowerShell 5.1. Invoke-WebRequest without -UseBasicParsing routes the response through the IE engine for DOM parsing, which needs IE first-run setup and can prompt; the call throws, Resolve-Version returns $null, and the script degrades to the mutable /releases/latest/download/ path. That is the stale-binary-with-matching- stale-checksum case the surrounding comment explicitly warns about, so the version pinning was defeated on every 5.1 install. The -OutFile downloads were unaffected because -OutFile skips HTML parsing, which is why only this step failed while the install still appeared to succeed. 2. Cleanup leaked files when the user profile contains a space. Windows hands back TEMP in 8.3 short form (C:\Users\WIN1~1\...) and the filesystem provider cannot resolve the tilde segment, so each cleanup call printed "An object at the specified path C:\Users\WIN1~1 does not exist" and left the downloaded binary and SHA256SUMS behind on every run. Passing -LiteralPath does not help; the short path must be expanded via GetLongPathName. Verified on Windows 11 / PowerShell 5.1 with profile "C:\Users\Win 1": before, "Could not resolve latest version" plus two cleanup errors and two leaked files; after, "Latest version: v1.0.146", checksum verified, exit 0, no leftovers. Co-Authored-By: Claude Opus 5 <noreply@anthropic.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.
Two independent bugs in
install.ps1, both of which fail silently on Windows. Found while installing on Windows 11 / Windows PowerShell 5.1 with a user profile containing a space (C:\Users\Win 1).1. Version pinning is defeated on Windows PowerShell 5.1
Resolve-VersioncallsInvoke-WebRequestwithout-UseBasicParsing. On PS 5.1 that routes the response through the Internet Explorer engine for DOM parsing, which requires IE first-run setup and can prompt. The call throws,Resolve-Versionreturns$null, and the script prints:That fallback is the mutable
/releases/latest/download/path — precisely the stale-binary case the comment aboveResolve-Versionwarns about:So on PS 5.1 the immutable-versioned-URL protection never engaged. This is the more consequential of the two bugs: the install still reports success, and the checksum still verifies, because the stale manifest matches the stale binary.
Worth noting the two
-OutFiledownloads were unaffected —-OutFileskips HTML parsing entirely. That asymmetry is why only this one step failed while everything else looked healthy, and why the failure is easy to miss. I added-UseBasicParsingto those two calls as well; it changes nothing today but removes the same latent IE dependency.2. Cleanup leaks files when the profile path contains a space
Windows reports
TEMPin 8.3 short form for such profiles (C:\Users\WIN1~1\AppData\Local\Temp). PowerShell's filesystem provider cannot resolve the~segment, so every cleanup call fails:The downloaded binary (~33 MB) and
SHA256SUMSare left inTEMPon every run, including every future upgrade.-LiteralPathdoes not fix this — I tested it; the short path itself has to be expanded viaGetLongPathName. The added block is a no-op whenTEMPis already long.Verification
Same machine, same shell, before and after.
Before:
→ 2 errors, 2 leaked files in
TEMP, downloaded from the mutable path.After:
→ exit 0, no errors, 0 leftovers, downloaded from the pinned immutable path.
Also confirmed the resulting install is healthy (
officecli --version→1.0.146) and thatResolve-Versionnow returnsv1.0.146from both the mirror and the GitHub fallback.Scope
Both changes are confined to
install.ps1. No behavior change on systems already unaffected:-UseBasicParsingis the recommended form on 5.1 and is the default and a no-op on PowerShell 7+, and the TEMP block only runs whenTEMPactually contains a~.🤖 Generated with Claude Code