Skip to content

fix(onboard): detect installed Windows Ollama when daemon is stopped#4089

Merged
cv merged 4 commits into
NVIDIA:mainfrom
Thabhelo:fix/onboard-wsl-ollama-known-path
Jun 3, 2026
Merged

fix(onboard): detect installed Windows Ollama when daemon is stopped#4089
cv merged 4 commits into
NVIDIA:mainfrom
Thabhelo:fix/onboard-wsl-ollama-known-path

Conversation

@Thabhelo
Copy link
Copy Markdown
Contributor

@Thabhelo Thabhelo commented May 22, 2026

Summary

Probe known Windows Ollama install paths even when the daemon is not running and ollama.exe is missing from PATH, so WSL onboarding offers Start Ollama on Windows host instead of Install.

Related Issue

Fixes #4066

Changes

  • Check GET_KNOWN_OLLAMA_INSTALL_PATH after PATH/process probes in probeInstalledPath()
  • Add regression test in src/lib/onboard/windows-host-ollama.test.ts

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • make docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Thabhelo 50872400+Thabhelo@users.noreply.github.com

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Enhanced detection of Ollama installations on Windows by checking standard installation paths even when the application is not actively running, ensuring more reliable setup detection.
  • Tests

    • Added unit test coverage for Windows Ollama detection functionality.

Review Change Stack

Probe known install paths even when Ollama is not on PATH and not running,
so WSL onboarding offers Start instead of Install.

Fixes NVIDIA#4066.
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 22, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

📝 Walkthrough

Walkthrough

This PR fixes detection of installed-but-not-running Ollama on Windows by removing a PID-visibility gate that was preventing fallback to known installer paths, and adds test coverage validating the corrected behavior.

Changes

Windows Ollama Detection Fallback

Layer / File(s) Summary
Probe path reordering in probeInstalledPath
src/lib/onboard/windows-host-ollama.ts
Removes PID gate that blocked fallback to known Ollama installer paths; now checks $LOCALAPPDATA\Programs\Ollama\ollama.exe before gating on process availability, allowing detection when Ollama is installed but not running.
detectWindowsHostOllama test for installed-but-not-running case
src/lib/onboard/windows-host-ollama.test.ts
Adds Vitest unit test mocking PowerShell execution and WSL detection to verify correct detection result when Ollama exists at known path but process is not running.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly Related PRs

  • NVIDIA/NemoClaw#3969: Related PR that introduced the initial Windows-host Ollama detection logic that this fix and test coverage target.

Suggested Labels

Platform: Windows/WSL, Local Models, fix

Suggested Reviewers

  • ericksoa

Poem

A rabbit hops through Windows halls,
Finding Ollama in its walls,
Not running now, but still there waits—
Detection works at any gates! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: detecting installed Windows Ollama when the daemon is stopped, which aligns with the core change in windows-host-ollama.ts.
Linked Issues check ✅ Passed The code changes fully address issue #4066: the probeInstalledPath() function now checks known install paths before the PID guard, allowing detection of installed-but-stopped Ollama, and a regression test validates this behavior.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing issue #4066: modifications to windows-host-ollama.ts and addition of windows-host-ollama.test.ts, with no unrelated alterations detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/onboard/windows-host-ollama.test.ts`:
- Around line 6-10: The mock for runCapture has the wrong signature; update the
mock declaration and implementation to match the real function signature
runCapture(cmd: readonly string[], opts: CaptureOptions = {}): string by
changing the vi.fn to accept two parameters (cmd: readonly string[], opts?:
CaptureOptions) and updating the vi.mock implementation to forward both
arguments (command and opts) to the runCapture mock; import or reference the
CaptureOptions type if needed so TypeScript types line up with the real
runCapture used by the tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1b2ee34a-c5d9-49ef-8684-74a3bfd69b7e

📥 Commits

Reviewing files that changed from the base of the PR and between da85c5d and 9329124.

📒 Files selected for processing (2)
  • src/lib/onboard/windows-host-ollama.test.ts
  • src/lib/onboard/windows-host-ollama.ts

Comment on lines +6 to +10
const runCapture = vi.fn<(command: string | string[]) => string>(() => "");

vi.mock("../runner", () => ({
runCapture: (command: string | string[]) => runCapture(command),
}));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix mock signature to match the real runCapture signature.

The mock signature doesn't match the actual runCapture function. Looking at src/lib/runner.ts:216-261, the real signature is:

function runCapture(cmd: readonly string[], opts: CaptureOptions = {}): string

But the mock only declares one parameter. This may cause TypeScript compilation errors when the code under test calls runCapture([...], { ignoreError: true }).

🔧 Proposed fix to match the real signature
-const runCapture = vi.fn<(command: string | string[]) => string>(() => "");
+const runCapture = vi.fn<(cmd: readonly string[], opts?: { ignoreError?: boolean }) => string>(() => "");

 vi.mock("../runner", () => ({
-  runCapture: (command: string | string[]) => runCapture(command),
+  runCapture: (cmd: readonly string[], opts?: { ignoreError?: boolean }) => runCapture(cmd, opts),
 }));

Then update the mock implementation to use the correct parameter name:

-    runCapture.mockImplementation((command) => {
-      const cmd = Array.isArray(command) ? command.join(" ") : command;
+    runCapture.mockImplementation((cmd) => {
+      const cmdStr = cmd.join(" ");
-      if (cmd.includes("Get-Command ollama.exe")) return "";
+      if (cmdStr.includes("Get-Command ollama.exe")) return "";
       // ... update other checks similarly
     });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/windows-host-ollama.test.ts` around lines 6 - 10, The mock
for runCapture has the wrong signature; update the mock declaration and
implementation to match the real function signature runCapture(cmd: readonly
string[], opts: CaptureOptions = {}): string by changing the vi.fn to accept two
parameters (cmd: readonly string[], opts?: CaptureOptions) and updating the
vi.mock implementation to forward both arguments (command and opts) to the
runCapture mock; import or reference the CaptureOptions type if needed so
TypeScript types line up with the real runCapture used by the tests.

@wscurran
Copy link
Copy Markdown
Contributor

✨ Thanks for submitting this detailed PR about detecting installed Windows Ollama when the daemon is stopped. This proposes a fix where the onboarding process checks known Windows Ollama install paths even when the daemon is not running and ollama.exe is missing from PATH.


Related open issues:

@wscurran wscurran added the v0.0.58 Release target label Jun 2, 2026
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output area: local-models Local model providers, downloads, launch, or connectivity area: providers Inference provider integrations and provider behavior bug-fix PR fixes a bug or regression platform: windows Affects native Windows environments platform: wsl Affects Windows Subsystem for Linux and removed Platform: Windows/WSL labels Jun 3, 2026
@prekshivyas
Copy link
Copy Markdown
Contributor

Code change is right — gating the known-install-path probe on a live PID was the bug.

Please address the CodeRabbit nit on src/lib/onboard/windows-host-ollama.test.ts:10: update the runCapture mock signature to match the real (cmd: readonly string[], opts: CaptureOptions = {}): string from src/lib/runner.ts:216. Will approve once that's resolved.

@prekshivyas
Copy link
Copy Markdown
Contributor

Two non-blocking notes for the record:

  • Semantic shift: installed=true is now driven by binary presence on disk rather than a live daemon. The new comment block captures the why (#4066), but doesn't note that the consumer-side Start/Restart gating is what preserves the #3949 launch safety. If you want to spell that out, ~2 lines added to the comment block would do it.
  • Branch coverage: the new test exercises 2 of 6 paths in this file (file went from 0 → 2 covered, net win). Untested: !isWsl() early return, both early-return paths inside probeInstalledPath, and the loopbackOnly listen-address check. Not gate-required, but a small follow-up adding two negative-path cases (isWsl=false and "all probes miss → installed=false") would close the obvious gaps.

@Thabhelo
Copy link
Copy Markdown
Contributor Author

Thabhelo commented Jun 3, 2026

Updated the runCapture mock signature to match runner.ts — thanks for the review.

Copy link
Copy Markdown
Contributor

@prekshivyas prekshivyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — root-cause fix for #4066 (drop the PID guard so probeInstalledPath reaches the known-install-path fallback on installed-but-not-running Ollama).

CR mock-signature nit addressed in cc0e54f — mock now uses readonly string[] matching runner.ts:215. Substantive CI verified on cc0e54f: 10 success / 0 failures across CodeQL, ShellCheck, dco-check, commit-lint, etc. The pending jobs on the latest merge SHA are concurrency replays of doc-only main-rollforward — no code change between cc0e54f and 9370710 beyond .agents/skills/* and docs/*.mdx from main.

The earlier non-blocking suggestion about negative-path tests stands as optional follow-up; not gating approval.

@Thabhelo
Copy link
Copy Markdown
Contributor Author

Thabhelo commented Jun 3, 2026

Cool, I will take care of those optional minor changes you highlighted after this gets merged.

@cv cv merged commit bb7e32b into NVIDIA:main Jun 3, 2026
17 checks passed
cv pushed a commit that referenced this pull request Jun 4, 2026
## Summary
Follow-up to #4089: add negative-path tests for
`detectWindowsHostOllama` and clarify that `installed` reflects on-disk
binary presence while onboard still gates Start/Restart on reachability
(#3949).

## Related Issue
Follow-up to #4089 (closed #4066).

## Changes
- Add tests for `!isWsl()` early return and all-probes-miss →
`installed: false`
- Document consumer-side Start/Restart gating in
`windows-host-ollama.ts`

## Type of Change
- [x] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Verification
- [ ] `npx prek run --all-files` passes
- [ ] `npm test` passes
- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed
- [ ] Docs updated for user-facing behavior changes
- [ ] `make docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Thabhelo <50872400+Thabhelo@users.noreply.github.com>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
  * Improved test coverage for Ollama detection on Windows.

* **Documentation**
* Added internal clarifications for detection behavior and system
integration.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output area: local-models Local model providers, downloads, launch, or connectivity area: providers Inference provider integrations and provider behavior bug-fix PR fixes a bug or regression platform: windows Affects native Windows environments platform: wsl Affects Windows Subsystem for Linux v0.0.58 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WSL2][Onboard] nemoclaw onboard shows "Install Ollama on Windows host" instead of "Start" when Ollama binary exists but is not running and not in PATH

4 participants