Skip to content

Commit e5928d6

Browse files
committed
fix(01-quickstart): don't abort on model inspect probe under ErrorActionPreference Stop
A missing model makes 'docker model inspect' write to stderr, which $ErrorActionPreference = 'Stop' turns into a terminating error, killing the script before the pull step on a fresh install. Lower the preference to Continue only around the probe and key off $LASTEXITCODE.
1 parent 504e23c commit e5928d6

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

01-quickstart/quickstart.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ if ($LASTEXITCODE -ne 0) {
2121
docker model status
2222

2323
Write-Host "==> 2/5 Pulling model '$Model' (skipped if already present)"
24+
# Probe for the model without aborting: a missing model makes `docker model inspect`
25+
# write to stderr, which $ErrorActionPreference = "Stop" would turn into a terminating error.
26+
$prevEap = $ErrorActionPreference
27+
$ErrorActionPreference = "Continue"
2428
docker model inspect $Model *> $null
25-
if ($LASTEXITCODE -eq 0) {
29+
$modelExists = $LASTEXITCODE -eq 0
30+
$ErrorActionPreference = $prevEap
31+
if ($modelExists) {
2632
Write-Host " '$Model' is already available locally, skipping pull."
2733
} else {
2834
docker model pull $Model

0 commit comments

Comments
 (0)