Skip to content

fix(ai): show friendly error when opencode CLI is unavailable - #1669

Merged
backnotprop merged 2 commits into
backnotprop:mainfrom
Aayushyaash:fix/opencode-enoent-friendly-error
Oct 3, 2026
Merged

backnotprop merged 2 commits into
backnotprop:mainfrom
Aayushyaash:fix/opencode-enoent-friendly-error

Conversation

@Aayushyaash

Copy link
Copy Markdown
Contributor

Closes #1503

Summary

When the opencode CLI is not installed or is not available on PATH, the opencode-sdk provider previously showed a raw ENOENT error.

This PR replaces it with a clear error message explaining that the CLI is missing and how to resolve it.

Changes

  • Catch ENOENT errors when starting the OpenCode server.
  • Show a user-friendly message when the opencode CLI is unavailable.
  • Preserve other errors unchanged.
  • Add tests for the error handling and recovery behavior.

Verification

  • bun test packages/ai/providers/opencode-sdk.test.ts — 8/8 passing
  • bun test packages/ai/ — 146/146 passing
  • tsc --noEmit -p packages/ai/tsconfig.json — 0 errors
  • Verified with PATH cleared that the friendly error is shown instead of the raw ENOENT error.

Aayushyaash and others added 2 commits October 3, 2026 12:40
…#1503)

When createOpencodeServer fails with ENOENT (e.g. opencode CLI not installed or missing from PATH), wrap and rethrow with an actionable error message advising the user to install the CLI or disable the provider, rather than letting raw uv_spawn ENOENT bubble up.
The message fallback (/ENOENT|not found/i) also matched the SDK's
'Server exited with code N' failures, which embed the child's stderr, so
an unrelated 'model not found' was misreported as a missing CLI. Node,
Bun and cross-spawn all set code ENOENT on a missing binary.

Reword the message to name the binary, link the install page, and point
at choosing another AI provider (there is no per-provider disable).
Tests assert the cause is preserved and that other failures pass through.
@backnotprop
backnotprop merged commit d8612a5 into backnotprop:main Oct 3, 2026
21 checks passed
@backnotprop

Copy link
Copy Markdown
Owner

Thanks @Aayushyaash, merged. I pushed one small change on top: it now detects a missing CLI by the error's ENOENT code only, because the message check also caught unrelated OpenCode startup errors like "model not found". I also reworded the message to point at installing OpenCode or picking another provider. It ships in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode provider: unhelpful ENOENT when the opencode CLI is not on PATH

2 participants