-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(onboard): offer Ollama upgrade when host version too old #4186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2a8e3aa
fix(onboard): offer Ollama upgrade when host version too old
laitingsheng d6c7199
refactor(onboard): extract Ollama install menu to satisfy entrypoint …
laitingsheng c39e816
refactor(onboard): brew upgrade on macOS, extract Ollama version helpers
laitingsheng cd08178
fix(onboard): force system upgrade and verify Ollama version after in…
laitingsheng 4be19f8
fix(onboard): verify upgrade via running daemon and reject user-local…
laitingsheng e7d34ed
fix(onboard): consider running daemon version when deciding Ollama up…
laitingsheng 262bbea
fix(onboard): scope Ollama daemon upgrade check to local host and lab…
laitingsheng c5b23c1
fix(onboard): pin resolved Ollama host after install and label stale …
laitingsheng 7612370
fix(onboard): start local Ollama daemon when only Windows-host probe …
laitingsheng 5c43b26
fix(onboard): re-probe loopback fresh instead of trusting cached reso…
laitingsheng 3f2b8b5
fix(onboard): guard env=system upgrade against missing sudo and unblo…
laitingsheng 373b05f
fix(onboard): stop stale Ollama daemon on macOS upgrade; drop unused …
laitingsheng 8497696
fix(onboard): stop stale Linux Ollama daemon before relaunch on non-s…
laitingsheng 0ecfbc0
Merge branch 'main' into fix/4178-ollama-version-upgrade
cv 74b8723
refactor(onboard): split Ollama Linux upgrade helpers
cv ba1b68f
Merge branch 'main' into fix/4178-ollama-version-upgrade
cv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { | ||
| getInstalledOllamaVersion, | ||
| isOllamaVersionAtLeast, | ||
| MIN_OLLAMA_VERSION, | ||
| } from "../../../dist/lib/inference/ollama-version"; | ||
|
|
||
| describe("Ollama version detection", () => { | ||
| it("parses 'ollama version is X.Y.Z' output", () => { | ||
| const capture = () => "ollama version is 0.6.2"; | ||
| expect(getInstalledOllamaVersion(capture)).toBe("0.6.2"); | ||
| }); | ||
|
|
||
| it("returns null when ollama --version produces no output", () => { | ||
| const capture = () => ""; | ||
| expect(getInstalledOllamaVersion(capture)).toBeNull(); | ||
| }); | ||
|
|
||
| it("returns null when ollama --version output has no version", () => { | ||
| const capture = () => "ollama: command not found"; | ||
| expect(getInstalledOllamaVersion(capture)).toBeNull(); | ||
| }); | ||
|
|
||
| it("treats null/missing versions as below the minimum", () => { | ||
| expect(isOllamaVersionAtLeast(null, MIN_OLLAMA_VERSION)).toBe(false); | ||
| }); | ||
|
|
||
| it("treats 0.6.2 as below the 0.7.0 floor", () => { | ||
| expect(isOllamaVersionAtLeast("0.6.2", "0.7.0")).toBe(false); | ||
| }); | ||
|
|
||
| it("treats 0.7.0 as meeting the 0.7.0 floor", () => { | ||
| expect(isOllamaVersionAtLeast("0.7.0", "0.7.0")).toBe(true); | ||
| }); | ||
|
|
||
| it("treats 0.24.0 as above the 0.7.0 floor", () => { | ||
| expect(isOllamaVersionAtLeast("0.24.0", "0.7.0")).toBe(true); | ||
| }); | ||
|
|
||
| it("treats 1.0.0 as above the 0.7.0 floor", () => { | ||
| expect(isOllamaVersionAtLeast("1.0.0", "0.7.0")).toBe(true); | ||
| }); | ||
|
|
||
| it("returns false for unparseable version components", () => { | ||
| expect(isOllamaVersionAtLeast("not-a-version", "0.7.0")).toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| /** | ||
| * Ollama version detection helpers. Kept separate from the larger | ||
| * `inference/local.ts` so the version-floor logic can evolve without | ||
| * dragging the rest of the local-inference helpers along. | ||
| */ | ||
|
|
||
| const { runCapture } = require("../runner"); | ||
|
|
||
| export type OllamaVersionRunCapture = ( | ||
| cmd: string | string[], | ||
| opts?: { ignoreError?: boolean }, | ||
| ) => string; | ||
|
|
||
| /** | ||
| * Minimum Ollama version NemoClaw expects when reusing an existing host | ||
| * Ollama. Older Ollama runners crash loading newer starter models because | ||
| * their GGUF parsers predate the model format. Bump this when starter-model | ||
| * recipes adopt a newer GGUF feature. | ||
| */ | ||
| export const MIN_OLLAMA_VERSION = "0.7.0"; | ||
|
|
||
| export function getInstalledOllamaVersion( | ||
| runCaptureImpl?: OllamaVersionRunCapture, | ||
| ): string | null { | ||
| const capture = runCaptureImpl ?? runCapture; | ||
| const out = capture(["ollama", "--version"], { ignoreError: true }); | ||
| if (!out) return null; | ||
| const match = out.match(/(\d+)\.(\d+)\.(\d+)/); | ||
| return match ? match[0] : null; | ||
| } | ||
|
|
||
| export function isOllamaVersionAtLeast( | ||
| version: string | null, | ||
| minimum: string, | ||
| ): boolean { | ||
| if (!version) return false; | ||
| const parts = version.split(".").map((v) => Number.parseInt(v, 10)); | ||
| const min = minimum.split(".").map((v) => Number.parseInt(v, 10)); | ||
| const len = Math.max(parts.length, min.length); | ||
| for (let i = 0; i < len; i += 1) { | ||
| const a = parts[i] ?? 0; | ||
| const b = min[i] ?? 0; | ||
| if (Number.isNaN(a) || Number.isNaN(b)) return false; | ||
| if (a > b) return true; | ||
| if (a < b) return false; | ||
| } | ||
| return true; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { resolveOllamaInstallMenuEntry } from "../../../dist/lib/onboard/ollama-install-menu"; | ||
| import { MIN_OLLAMA_VERSION } from "../../../dist/lib/inference/ollama-version"; | ||
|
|
||
| const LINUX_NON_WSL = { platform: "linux" as const, isWsl: false }; | ||
|
|
||
| describe("resolveOllamaInstallMenuEntry", () => { | ||
| it("offers a fresh install when no Ollama is present", () => { | ||
| const result = resolveOllamaInstallMenuEntry({ | ||
| hasOllama: false, | ||
| ollamaRunning: false, | ||
| hasWindowsOllama: false, | ||
| installedOllamaVersion: null, | ||
| ...LINUX_NON_WSL, | ||
| }); | ||
| expect(result.hasUpgradableOllama).toBe(false); | ||
| expect(result.entry?.key).toBe("install-ollama"); | ||
| expect(result.entry?.label).toBe("Install Ollama (Linux)"); | ||
| }); | ||
|
|
||
| it("offers an upgrade entry when host Ollama is below the minimum", () => { | ||
| const result = resolveOllamaInstallMenuEntry({ | ||
| hasOllama: true, | ||
| ollamaRunning: true, | ||
| hasWindowsOllama: false, | ||
| installedOllamaVersion: "0.6.2", | ||
| ...LINUX_NON_WSL, | ||
| }); | ||
| expect(result.hasUpgradableOllama).toBe(true); | ||
| expect(result.entry?.key).toBe("install-ollama"); | ||
| expect(result.entry?.label).toBe( | ||
| `Upgrade Ollama (Linux) — upgrade installed 0.6.2 to ≥ ${MIN_OLLAMA_VERSION}`, | ||
| ); | ||
| }); | ||
|
|
||
| it("omits the entry when host Ollama meets the minimum", () => { | ||
| const result = resolveOllamaInstallMenuEntry({ | ||
| hasOllama: true, | ||
| ollamaRunning: true, | ||
| hasWindowsOllama: false, | ||
| installedOllamaVersion: "0.24.0", | ||
| ...LINUX_NON_WSL, | ||
| }); | ||
| expect(result.hasUpgradableOllama).toBe(false); | ||
| expect(result.entry).toBeNull(); | ||
| }); | ||
|
|
||
| it("omits the entry when only Windows-host Ollama is present", () => { | ||
| const result = resolveOllamaInstallMenuEntry({ | ||
| hasOllama: false, | ||
| ollamaRunning: false, | ||
| hasWindowsOllama: true, | ||
| installedOllamaVersion: null, | ||
| ...LINUX_NON_WSL, | ||
| }); | ||
| expect(result.entry).toBeNull(); | ||
| }); | ||
|
|
||
| it("treats null versions as below the minimum to recover stale installs", () => { | ||
| const result = resolveOllamaInstallMenuEntry({ | ||
| hasOllama: true, | ||
| ollamaRunning: true, | ||
| hasWindowsOllama: false, | ||
| installedOllamaVersion: null, | ||
| ...LINUX_NON_WSL, | ||
| }); | ||
| expect(result.hasUpgradableOllama).toBe(true); | ||
| expect(result.entry?.label).toBe( | ||
| `Upgrade Ollama (Linux) — upgrade installed unknown to ≥ ${MIN_OLLAMA_VERSION}`, | ||
| ); | ||
| }); | ||
|
|
||
| it("labels WSL Linux distinctly when the host is WSL", () => { | ||
| const result = resolveOllamaInstallMenuEntry({ | ||
| hasOllama: false, | ||
| ollamaRunning: false, | ||
| hasWindowsOllama: false, | ||
| installedOllamaVersion: null, | ||
| platform: "linux", | ||
| isWsl: true, | ||
| }); | ||
| expect(result.entry?.label).toBe("Install Ollama (WSL Linux)"); | ||
| }); | ||
|
|
||
| it("labels macOS distinctly", () => { | ||
| const result = resolveOllamaInstallMenuEntry({ | ||
| hasOllama: false, | ||
| ollamaRunning: false, | ||
| hasWindowsOllama: false, | ||
| installedOllamaVersion: null, | ||
| platform: "darwin", | ||
| isWsl: false, | ||
| }); | ||
| expect(result.entry?.label).toBe("Install Ollama (macOS)"); | ||
| }); | ||
|
|
||
| it("labels macOS upgrade case so the Homebrew branch can pick brew upgrade", () => { | ||
| const result = resolveOllamaInstallMenuEntry({ | ||
| hasOllama: true, | ||
| ollamaRunning: true, | ||
| hasWindowsOllama: false, | ||
| installedOllamaVersion: "0.6.2", | ||
| platform: "darwin", | ||
| isWsl: false, | ||
| }); | ||
| expect(result.hasUpgradableOllama).toBe(true); | ||
| expect(result.entry?.label).toBe( | ||
| `Upgrade Ollama (macOS) — upgrade installed 0.6.2 to ≥ ${MIN_OLLAMA_VERSION}`, | ||
| ); | ||
| }); | ||
|
|
||
| it("does not return an entry on unsupported platforms", () => { | ||
| const result = resolveOllamaInstallMenuEntry({ | ||
| hasOllama: false, | ||
| ollamaRunning: false, | ||
| hasWindowsOllama: false, | ||
| installedOllamaVersion: null, | ||
| platform: "win32", | ||
| isWsl: false, | ||
| }); | ||
| expect(result.entry).toBeNull(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { | ||
| getInstalledOllamaVersion, | ||
| isOllamaVersionAtLeast, | ||
| MIN_OLLAMA_VERSION, | ||
| } from "../inference/ollama-version"; | ||
|
|
||
| export interface OllamaInstallMenuInput { | ||
| hasOllama: boolean; | ||
| ollamaRunning: boolean; | ||
| hasWindowsOllama: boolean; | ||
| platform: NodeJS.Platform; | ||
| isWsl: boolean; | ||
| /** Override for tests. Defaults to a live `ollama --version` probe. */ | ||
| installedOllamaVersion?: string | null; | ||
| } | ||
|
|
||
| export interface OllamaInstallMenuEntry { | ||
| key: "install-ollama"; | ||
| label: string; | ||
| } | ||
|
|
||
| export interface OllamaInstallMenuResult { | ||
| entry: OllamaInstallMenuEntry | null; | ||
| hasUpgradableOllama: boolean; | ||
| } | ||
|
|
||
| function osTagFor(platform: NodeJS.Platform, isWsl: boolean): string | null { | ||
| if (platform === "darwin") return "macOS"; | ||
| if (platform === "linux") return isWsl ? "WSL Linux" : "Linux"; | ||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Decide whether the onboard provider menu should expose an `install-ollama` | ||
| * entry, and which label to render. Two cases: | ||
| * | ||
| * 1. No Ollama anywhere (host, running, or Windows) — offer a fresh install | ||
| * as a fallback (e.g. when the NVIDIA API server is down and cloud keys | ||
| * are unavailable). | ||
| * 2. Host Ollama exists but its version is below `MIN_OLLAMA_VERSION` — | ||
| * offer an explicit upgrade so the express setup path doesn't reuse a | ||
| * daemon that crashes loading newer starter models. | ||
| */ | ||
| export function resolveOllamaInstallMenuEntry( | ||
| input: OllamaInstallMenuInput, | ||
| ): OllamaInstallMenuResult { | ||
| const installedOllamaVersion = | ||
| input.installedOllamaVersion !== undefined | ||
| ? input.installedOllamaVersion | ||
| : input.hasOllama | ||
| ? getInstalledOllamaVersion() | ||
| : null; | ||
| const hasUpgradableOllama = | ||
| input.hasOllama && !isOllamaVersionAtLeast(installedOllamaVersion, MIN_OLLAMA_VERSION); | ||
| const showEntry = | ||
| (!input.hasOllama && !input.ollamaRunning && !input.hasWindowsOllama) || hasUpgradableOllama; | ||
| if (!showEntry) { | ||
| return { entry: null, hasUpgradableOllama }; | ||
| } | ||
| const osTag = osTagFor(input.platform, input.isWsl); | ||
| if (osTag === null) { | ||
| return { entry: null, hasUpgradableOllama }; | ||
| } | ||
| const labelPrefix = hasUpgradableOllama ? "Upgrade Ollama" : "Install Ollama"; | ||
| const upgradeSuffix = hasUpgradableOllama | ||
| ? ` — upgrade installed ${installedOllamaVersion ?? "unknown"} to ≥ ${MIN_OLLAMA_VERSION}` | ||
| : ""; | ||
| return { | ||
| entry: { key: "install-ollama", label: `${labelPrefix} (${osTag})${upgradeSuffix}` }, | ||
| hasUpgradableOllama, | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.