Uh oh!
There was an error while loading. Please reload this page.
Conversation
- Updated the method for checking Docker's running status to use a more concise syntax, improving readability and maintaining functionality.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Stale
$LASTEXITCODEcauses false Docker running detection- Reintroduced try/catch around both
docker infochecks soCommandNotFoundExceptionno longer falls through to stale$LASTEXITCODElogic.
- Reintroduced try/catch around both
Or push these changes by commenting:
@cursor push e1108e46e8
Preview (e1108e46e8)
diff --git a/scripts/install-k8s.ps1 b/scripts/install-k8s.ps1--- a/scripts/install-k8s.ps1+++ b/scripts/install-k8s.ps1@@ -417,7 +417,7 @@
}
$dockerRunning = $false
- docker info *>$null 2>&1; if ($LASTEXITCODE -eq 0) { $dockerRunning = $true }+ try { docker info *>$null 2>&1; if ($LASTEXITCODE -eq 0) { $dockerRunning = $true } } catch {}
if (-not $dockerRunning) {
Start-Process $dockerExe -ErrorAction SilentlyContinue
@@ -428,7 +428,7 @@
$f = 0
for ($i = 1; $i -le $maxWait; $i++) {
Start-Sleep -Seconds 3
- docker info *>$null 2>&1; if ($LASTEXITCODE -eq 0) { $dockerRunning = $true; break }+ try { docker info *>$null 2>&1; if ($LASTEXITCODE -eq 0) { $dockerRunning = $true; break } } catch {}
Write-Host "`r " -NoNewline
Write-Host $frames[$f] -ForegroundColor Cyan -NoNewline
Write-Host " Waiting for Docker..." -NoNewline| $dockerRunning = $false | ||
| try { docker info 2>&1 | Out-Null; $dockerRunning = ($LASTEXITCODE -eq 0) } catch {} | ||
| docker info *>$null 2>&1; if ($LASTEXITCODE -eq 0) { $dockerRunning = $true } |
There was a problem hiding this comment.
Stale $LASTEXITCODE causes false Docker running detection
High Severity
Removing the try/catch around docker info introduces a false-positive detection bug. When docker is not in PATH, PowerShell throws a CommandNotFoundException (statement-terminating, not script-terminating), so execution continues to the if ($LASTEXITCODE -eq 0) check. Since no native command actually ran, $LASTEXITCODE retains its previous value — likely 0 from a preceding winget install — causing $dockerRunning to be incorrectly set to $true. The old try/catch prevented this by skipping the $LASTEXITCODE check on exception.



Note
Medium Risk
Small but user-facing installer change: removing
try/catchmay alter behavior when thedockerCLI is missing/unavailable, potentially causing the script to fail earlier during setup.Overview
Refactors Docker readiness detection in the Windows installer by replacing
try/catch { docker info ... }probes with a simplerdocker info *>$nullcall that checks$LASTEXITCODEboth initially and inside the startup wait loop.This keeps the same overall flow (probe → launch Docker Desktop → poll until ready) while changing how errors/output from
docker infoare handled.Written by Cursor Bugbot for commit 4b30204. This will update automatically on new commits. Configure here.