fix(install-windows): don't let a missing Ollama process abort the last step
taskkill writes to stderr when the process isn't running, and with $ErrorActionPreference = Stop PowerShell 5.1 promotes native stderr to a terminating error (2>$null doesn't prevent it). The normal case -- Ollama not running -- threw and printed a failure warning for work that had succeeded. Uses Get-Process | Stop-Process instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+10
-2
@@ -228,8 +228,16 @@ try {
|
|||||||
Remove-Item $ollamaAutostart -Force
|
Remove-Item $ollamaAutostart -Force
|
||||||
Write-OK "Removed Ollama login autostart"
|
Write-OK "Removed Ollama login autostart"
|
||||||
}
|
}
|
||||||
foreach ($img in @("ollama app.exe", "ollama.exe")) {
|
# Get-Process, not taskkill: taskkill writes "ERROR: The process ... not
|
||||||
taskkill /F /T /IM $img 2>$null | Out-Null
|
# found." to stderr when nothing is running, and with $ErrorActionPreference
|
||||||
|
# = Stop PowerShell 5.1 promotes a native command's stderr to a TERMINATING
|
||||||
|
# error. `2>$null` does not prevent that. So the ordinary case - Ollama
|
||||||
|
# simply is not running - aborted this whole block and printed the warning
|
||||||
|
# below, claiming the install could not configure something it had in fact
|
||||||
|
# already done. Cmdlets have no such trap.
|
||||||
|
foreach ($name in @("ollama app", "ollama")) {
|
||||||
|
Get-Process -Name $name -ErrorAction SilentlyContinue |
|
||||||
|
Stop-Process -Force -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
Write-OK "Ollama set to manual start"
|
Write-OK "Ollama set to manual start"
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user