From 06921987197b556a5eed20567aa7a8f182981f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Sat, 18 Jul 2026 11:37:08 -0400 Subject: [PATCH] install.ps1: fix PropertyNotFoundStrict crash in the PATH check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Under the script's own Set-StrictMode -Version Latest, .Count on the result of Where-Object throws when the filter matches nothing — which is precisely the fresh-install case (bin dir not on PATH yet), so every first-time Windows install ended with an error after an otherwise successful install. Use -contains on the split arrays instead; no member access on a possibly-null pipeline result. Repro + fix verified under pwsh 7.5.2 with StrictMode Latest: old expression reproduces the user's exact error, new one returns False/True correctly for missing/present PATH entries. --- install.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install.ps1 b/install.ps1 index 5d78059..d6b4be3 100644 --- a/install.ps1 +++ b/install.ps1 @@ -131,9 +131,12 @@ try { Write-Host "" Write-Host "kigi v$ResolvedVersion installed to $Dest" + # -contains instead of Where-Object/.Count: under Set-StrictMode, .Count + # on an empty (null) filter result throws PropertyNotFoundStrict — which + # fired on every fresh install, since that's exactly the not-on-PATH case. $UserPath = [Environment]::GetEnvironmentVariable("Path", "User") - $OnPath = ($UserPath -split ";" | Where-Object { $_ -eq $BinDir }).Count -gt 0 -or - ($env:Path -split ";" | Where-Object { $_ -eq $BinDir }).Count -gt 0 + $OnPath = (($UserPath -split ";") -contains $BinDir) -or + (($env:Path -split ";") -contains $BinDir) if (-not $OnPath) { Write-Host "" Write-Host "$BinDir is not on your PATH. Add it for the current user with:"