Skip to content

fix: resolve native addon dependencies for Desktop tool#8

Merged
jairad26 merged 1 commit intojairad26:devfrom
NicholasDominici:fix/desktop-tool-native-deps
Mar 31, 2026
Merged

fix: resolve native addon dependencies for Desktop tool#8
jairad26 merged 1 commit intojairad26:devfrom
NicholasDominici:fix/desktop-tool-native-deps

Conversation

@NicholasDominici
Copy link
Copy Markdown
Collaborator

Summary

  • Add transitive @nut-tree-fork dependencies (libnut, libnut-darwin, shared) to packages/opencode/package.json so native .node bindings resolve correctly at runtime
  • Improve error handling in desktop.ts to surface the actual underlying error instead of a generic message, making debugging easier

Problem

The Desktop tool (@nut-tree-fork/nut-js) failed to load with the error:

Desktop automation library not available. Please ensure @nut-tree-fork/nut-js is installed.

Even though @nut-tree-fork/nut-js was installed, its transitive native addon dependencies (@nut-tree-fork/libnut, @nut-tree-fork/libnut-darwin, etc.) were not declared as direct dependencies. Bun's package manager didn't properly symlink these into the packages/opencode/node_modules directory, causing the dynamic require() calls inside the library to fail.

Changes

packages/opencode/package.json

Added missing transitive dependencies:

"@nut-tree-fork/libnut": "4.2.6",
"@nut-tree-fork/libnut-darwin": "2.7.5",
"@nut-tree-fork/shared": "4.2.6"

packages/opencode/src/tool/desktop.ts

  • Added error caching to avoid repeated failed imports
  • Error messages now include the actual underlying error (e.g., MODULE_NOT_FOUND) instead of a generic message
  • Added platform/arch logging for easier debugging

Add transitive @nut-tree-fork dependencies (libnut, libnut-darwin, shared)
to package.json so native .node bindings resolve correctly at runtime.

Improve error handling in desktop.ts to surface the actual underlying error
instead of a generic message, making debugging easier.
@jairad26 jairad26 merged commit dc3b365 into jairad26:dev Mar 31, 2026
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.

2 participants