Skip to content

Commit 77b588b

Browse files
committed
fix(windows): give Start-Process distinct stdout/stderr files
Start-Process refuses to use the same path for both -RedirectStandardOutput and -RedirectStandardError, which broke the Ollama serve helper and the CI run.ps1 smoke. Split into .out.log / .err.log. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e4a2243 commit 77b588b

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,18 @@ jobs:
217217
TUTOR_SKIP_OLLAMA: "1"
218218
run: |
219219
$ErrorActionPreference = 'Stop'
220-
$log = Join-Path $env:RUNNER_TEMP 'run-ps1-smoke.log'
221-
New-Item -ItemType File -Force -Path $log | Out-Null
220+
$outLog = Join-Path $env:RUNNER_TEMP 'run-ps1-smoke.out.log'
221+
$errLog = Join-Path $env:RUNNER_TEMP 'run-ps1-smoke.err.log'
222+
New-Item -ItemType File -Force -Path $outLog | Out-Null
223+
New-Item -ItemType File -Force -Path $errLog | Out-Null
222224
# Launch run.ps1 in a detached pwsh so the parent job can poll
223225
# /api/health without waiting on Start-Job module init.
224-
$args = @(
226+
$procArgs = @(
225227
'-NoProfile','-NoLogo','-File','run.ps1',
226228
'-SkipOllama','-Port','8802'
227229
)
228-
$proc = Start-Process -FilePath 'pwsh' -ArgumentList $args `
229-
-RedirectStandardOutput $log -RedirectStandardError $log `
230+
$proc = Start-Process -FilePath 'pwsh' -ArgumentList $procArgs `
231+
-RedirectStandardOutput $outLog -RedirectStandardError $errLog `
230232
-PassThru -WorkingDirectory (Get-Location).Path
231233
try {
232234
$ok = $false
@@ -240,8 +242,10 @@ jobs:
240242
if ($proc.HasExited) { break }
241243
}
242244
if (-not $ok) {
243-
Write-Host '--- run.ps1 output ---'
244-
if (Test-Path $log) { Get-Content -LiteralPath $log }
245+
Write-Host '--- run.ps1 stdout ---'
246+
if (Test-Path $outLog) { Get-Content -LiteralPath $outLog }
247+
Write-Host '--- run.ps1 stderr ---'
248+
if (Test-Path $errLog) { Get-Content -LiteralPath $errLog }
245249
throw "/api/health did not return 200 within 120s (proc exited=$($proc.HasExited))"
246250
}
247251
Write-Host 'ok /api/health -> 200'

install.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,24 +430,26 @@ function Install-OllamaNow {
430430

431431
function Start-OllamaNow {
432432
Say "starting 'ollama serve' in the background"
433-
$logPath = Join-Path ([IO.Path]::GetTempPath()) 'ollama-serve.log'
433+
# Start-Process requires distinct files for stdout vs stderr.
434+
$outLog = Join-Path ([IO.Path]::GetTempPath()) 'ollama-serve.out.log'
435+
$errLog = Join-Path ([IO.Path]::GetTempPath()) 'ollama-serve.err.log'
434436
try {
435437
$p = Start-Process -FilePath 'ollama' -ArgumentList 'serve' `
436-
-RedirectStandardOutput $logPath -RedirectStandardError $logPath `
438+
-RedirectStandardOutput $outLog -RedirectStandardError $errLog `
437439
-WindowStyle Hidden -PassThru
438440
} catch {
439441
ErrMsg "failed to start 'ollama serve': $($_.Exception.Message)"
440442
return $false
441443
}
442444
for ($i = 0; $i -lt 20; $i++) {
443445
if (Test-OllamaDaemon) {
444-
Ok ("ollama serve is up (pid {0}; log: {1})" -f $p.Id, $logPath)
446+
Ok ("ollama serve is up (pid {0}; logs: {1}, {2})" -f $p.Id, $outLog, $errLog)
445447
return $true
446448
}
447449
Start-Sleep -Milliseconds 500
448450
}
449451
ErrMsg 'ollama serve did not become reachable on :11434 within 10s.'
450-
ErrMsg "Inspect $logPath or run 'ollama serve' in another terminal."
452+
ErrMsg "Inspect $outLog / $errLog or run 'ollama serve' in another terminal."
451453
return $false
452454
}
453455

run.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,19 @@ function Test-OllamaDaemon {
153153

154154
function Start-OllamaNow {
155155
Say "starting 'ollama serve' in the background"
156-
$logPath = Join-Path ([IO.Path]::GetTempPath()) 'ollama-serve.log'
156+
$outLog = Join-Path ([IO.Path]::GetTempPath()) 'ollama-serve.out.log'
157+
$errLog = Join-Path ([IO.Path]::GetTempPath()) 'ollama-serve.err.log'
157158
try {
158159
$p = Start-Process -FilePath 'ollama' -ArgumentList 'serve' `
159-
-RedirectStandardOutput $logPath -RedirectStandardError $logPath `
160+
-RedirectStandardOutput $outLog -RedirectStandardError $errLog `
160161
-WindowStyle Hidden -PassThru
161162
} catch {
162163
ErrMsg "failed to start 'ollama serve': $($_.Exception.Message)"
163164
return $false
164165
}
165166
for ($i = 0; $i -lt 20; $i++) {
166167
if (Test-OllamaDaemon) {
167-
Ok ("ollama serve is up (pid {0}; log: {1})" -f $p.Id, $logPath)
168+
Ok ("ollama serve is up (pid {0}; logs: {1}, {2})" -f $p.Id, $outLog, $errLog)
168169
return $true
169170
}
170171
Start-Sleep -Milliseconds 500

0 commit comments

Comments
 (0)