Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/lib/onboard/windows-host-ollama.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { afterEach, describe, expect, it, vi } from "vitest";

const runCapture = vi.fn<(cmd: readonly string[]) => string>(() => "");

vi.mock("../runner", () => ({
runCapture: (cmd: readonly string[]) => runCapture(cmd),
}));

vi.mock("../platform", () => ({
isWsl: vi.fn(() => true),
}));

import { isWsl } from "../platform";
import { detectWindowsHostOllama } from "./windows-host-ollama";

describe("detectWindowsHostOllama", () => {
afterEach(() => {
vi.clearAllMocks();
vi.mocked(isWsl).mockReturnValue(true);
});

it("detects installed-but-not-running Ollama via known install path (#4066)", () => {
const knownPath = "C:\\Users\\tester\\AppData\\Local\\Programs\\Ollama\\ollama.exe";
runCapture.mockImplementation((command: readonly string[]) => {
const cmd = command.join(" ");
if (cmd.includes("Get-Command ollama.exe")) return "";
if (cmd.includes("Get-Process ollama") && cmd.includes("Path")) return "";
if (cmd.includes("Get-Process ollama") && cmd.includes("Id")) return "";
if (cmd.includes("Test-Path -LiteralPath")) return knownPath;
if (cmd.includes("Get-NetTCPConnection")) return "";
return "";
});

expect(detectWindowsHostOllama()).toEqual({
installed: true,
installedPath: knownPath,
loopbackOnly: false,
});
});
});
9 changes: 3 additions & 6 deletions src/lib/onboard/windows-host-ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ function probeInstalledPath(): string {
// lookup (#3949).
const processPath = powershell(GET_PROCESS_OLLAMA_PATH);
if (processPath.length > 0) return processPath;
// Some WSL-launched PowerShell sessions can see the Windows ollama PID
// but cannot read the Path property. Only after observing the live
// daemon, fall back to fixed installer locations so the restart path
// still has an explicit executable to launch.
const pid = powershell(GET_PROCESS_OLLAMA_ID);
if (!pid) return "";
// Silent installs often land in fixed locations without updating PATH or
// leaving a running daemon to probe. Check those paths even when no PID is
// visible so WSL onboarding offers Start instead of Install (#4066).
return powershell(GET_KNOWN_OLLAMA_INSTALL_PATH);
}

Expand Down