Skip to content
This repository was archived by the owner on Jul 4, 2026. It is now read-only.
This repository was archived by the owner on Jul 4, 2026. It is now read-only.

Fix for windows not installing models correctly #42

Description

@okretsej

i had a problem with the models not being loaded in. coming back as a null even tho it gave a success marker. now as why i am here should be obvious for an LLM portable. as i use LLMs daily. i had this issue fixed for you, i dont know where or if you had one already done. so here is the snippet from perplexity about the windows install since i am not using the other OS's atm, along with the code fixes, i ran it it worked out things load now.

Root Cause Analysis — install-core.ps1

Three bugs existed on a single line (line 472):

$null = & "$USB_Drive\Shared\bin\ollama-windows.exe" create $m.Local -f "Modelfile-$($m.Local)" 2>&1

Bug 1 — Silent failures:
$null = discards all output including errors. When ollama create failed,
the script printed "imported successfully!" anyway and moved on invisibly.

Bug 2 — Broken ZIP extraction (line 418):
The installer downloaded ollama-windows-amd64.zip but only moved ollama.exe
out of it, discarding llama-server.exe, llama-quantize.exe, and all runtime
DLLs bundled in the same ZIP. The installer was breaking its own engine on
every fresh install.

Bug 3 — Premature create call (line 467):
Start-Sleep -Seconds 5 is a blind wait. On a USB drive Ollama often isn't
ready in 5 seconds, so ollama create was hitting an unresponsive server.

════════════════════════════════════════════════════════════
FIX 1 — Verbose ollama create output
════════════════════════════════════════════════════════════

Replace:
try {
$null = & "$USB_Drive\Shared\bin\ollama-windows.exe" create $m.Local -f "Modelfile-$($m.Local)" 2>&1
Write-Host " $($m.Name) imported successfully!" -ForegroundColor Green
} catch {
Write-Host " ERROR: Failed to import $($m.Name)" -ForegroundColor Red
}

With:
Write-Host " Running: ollama-windows.exe create $($m.Local) -f Modelfile-$($m.Local)" -ForegroundColor DarkGray
$createOutput = & "$USB_Drive\Shared\bin\ollama-windows.exe" create $m.Local -f "Modelfile-$($m.Local)" 2>&1
Write-Host " Output: $createOutput" -ForegroundColor DarkGray
if ($LASTEXITCODE -eq 0) {
Write-Host " $($m.Name) imported successfully!" -ForegroundColor Green
} else {
Write-Host " ERROR: Failed to import $($m.Name) (exit $LASTEXITCODE)" -ForegroundColor Red
Write-Host " $createOutput" -ForegroundColor Red
}

════════════════════════════════════════════════════════════
FIX 2 — Extract ALL binaries from the Ollama ZIP
════════════════════════════════════════════════════════════

Replace the extraction block with:
New-Item -ItemType Directory -Force -Path $TempOllamaDir | Out-Null
Expand-Archive -Path $OllamaDest -DestinationPath $TempOllamaDir -Force

Get-ChildItem -Path $TempOllamaDir -Recurse -File | ForEach-Object {
    $dest = "$USB_Drive\Shared\bin\$($_.Name)"
    Move-Item -Path $_.FullName -Destination $dest -Force
    Write-Host "      Extracted: $($_.Name)" -ForegroundColor DarkGray
}

if (Test-Path "$USB_Drive\Shared\bin\ollama.exe") {
    Rename-Item "$USB_Drive\Shared\bin\ollama.exe" "ollama-windows.exe" -Force
}

Remove-Item $TempOllamaDir -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item $OllamaDest -Force -ErrorAction SilentlyContinue
Write-Host "      Ollama Setup Complete!" -ForegroundColor Green

════════════════════════════════════════════════════════════
FIX 3 — Wait until Ollama is actually ready
════════════════════════════════════════════════════════════

Replace:
Start-Sleep -Seconds 5

With:
Write-Host " Waiting for Ollama to be ready..." -ForegroundColor DarkGray
$waited = 0
do {
Start-Sleep -Seconds 1
$waited++
$response = & curl.exe -s http://127.0.0.1:11434/api/tags 2>&1
} while ($response -notmatch '"models"' -and $waited -lt 30)
if ($waited -ge 30) {
Write-Host " WARNING: Ollama did not respond in 30 seconds!" -ForegroundColor Red
} else {
Write-Host " Ollama is ready (took ${waited}s)." -ForegroundColor Green
}

════════════════════════════════════════════════════════════
REMAINING WATCH POINTS (priority order)
════════════════════════════════════════════════════════════

  1. chat_server.py ~line 722
    Empty model field proxied directly to Ollama → 400
    Fix: validate model exists before proxying

  2. FastChatUI.html fetchModels()
    No retry if /api/tags returns [] on first load
    Fix: add retry loop with backoff

  3. start-fast-chat.bat
    start /b hides Ollama window, crashes invisible
    Fix: use visible window during debugging

  4. chat_server.py _proxy_ollama()
    No request body validation at all
    Fix: add schema check before forwarding

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions