Skip to content

plugins for V2: local plugin paths fail to load (file entries rejected, @opencode/plugin unresolvable) #49608

Closed as duplicate

Description

@CerebroCanibalus

Description

A local plugin cannot be loaded by following the documentation.

  1. A plugins entry pointing at a .ts file is rejected with
    WARN "configured plugin path must be a directory", and the plugin never loads. The plugins
    documentation shows exactly this form (./plugins/local, ../shared/plugin.ts,
    /absolute/path/plugin.ts, file:///home/me/plugins/local).

  2. An entry pointing at a directory (or a plugin discovered under .opencode/plugins/) is found and
    imported, but loading fails because the documented import is not resolvable:

    level=INFO  message="loading plugin"  id=…/mi-plugin  entrypoint=file:///…/mi-plugin/index.ts
    level=WARN  message="failed to load plugin"
      cause="Cause([Die(ResolveMessage: Cannot find package '@opencode/plugin' imported from …\mi-plugin\index.ts)])"
    

    This happens with both loading paths (config entry and discovery). It only works if the plugin
    directory ships its own node_modules.

In both cases the failure is silent outside the log — no error in the session, no hint in the TUI —
so the only visible symptom is that the plugin's tools and hooks do not exist.

Plugins

None configured globally. The reproductions use a single project entry in opencode.jsonc and a
directory under .opencode/plugins/.

OpenCode version

2.0.3 (@opencode/cli installed globally with npm)

Steps to reproduce

A. plugins entry pointing at a .ts file

  1. Create a local plugin with a single default export: export default { id: "x", setup() {} }.

  2. Configure the entry: { "plugins": ["C:/absolute/path/mi-plugin/index.ts"] }.

  3. Start any session in that project (opencode run --standalone --print-logs --log-level info).

    Log: level=WARN message="configured plugin path must be a directory" target=C:/absolute/path/mi-plugin/index.ts

B. Directory entry or .opencode/plugins/ discovery importing @opencode/plugin

  1. Create <project>/.opencode/plugins/mi-plugin/index.ts:

    import { Plugin } from "@opencode/plugin"
    
    export default Plugin.define({
      id: "mi-plugin",
      async setup() {},
    })
  2. Start a session in that project.

    The module is found, then loading fails with the Cannot find package '@opencode/plugin' cause above.

Screenshot and/or share link

N/A — both failures are only visible in the server log; the log lines are quoted above.

Operating System

Windows 10 Enterprise LTSC 10.0.19044 (x64)

Terminal

Not applicable: reproduced headlessly with opencode run --standalone from PowerShell 5.1
(TERM=xterm-256color, TERM_PROGRAM unset, %COMSPEC% = cmd.exe).


Additional context (not part of the form):

  • Workarounds that work: export a plain object (export default { id, setup }) instead of
    Plugin.define; or run an install inside the plugin directory so @opencode/plugin resolves
    locally (@opencode/plugin@2.0.5 is published on npm).
  • Why this matters: the first case is a documentation/behaviour mismatch, and the second blocks
    every local (non-published) plugin that follows the documented import. Both fail silently, which
    makes them expensive to diagnose.
  • Notes: tested with the path written as C:/… and C:\…; opencode plugin list does not load
    project plugins, so it cannot be used to verify. Reproduced consistently on 2.0.3.

Activity

  1. changed the title [-]plugins: local plugin paths fail to load (file entries rejected, @opencode/plugin unresolvable)[/-] [+]plugins for V2: local plugin paths fail to load (file entries rejected, @opencode/plugin unresolvable)[/+] on Sep 17, 2026
  2. github-actions commented on Sep 17, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your report adds new information (e.g. the @opencode/plugin package resolution failure being distinct from the mtime query-string issue in #42763, or the .opencode/plugins/ discovery path being affected), please note that in those issues or confirm that this is a separate root cause worth tracking independently.

  3. wppqqppq commented on Oct 13, 2026

    @wppqqppq

    Data point for the second half of this report, on opencode 2.0.27 (latest, macOS): a plugin loaded by discovery from .opencode/plugins/ does resolve import { Plugin } from "@opencode/plugin" with no node_modules anywhere in scope.

    Isolated reproduction — session cwd /tmp/oc-probe, plugin at /tmp/oc-probe/.opencode/plugins/probe.ts:

    import { Plugin } from "@opencode/plugin"
    export default Plugin.define({ id: "nm-probe", async setup() {} })

    There is no node_modules in /tmp/oc-probe, /tmp, or /, and no repo node_modules is an ancestor, so only a host-provided module could satisfy the import. Result:

    msg="loading plugin" id=/private/tmp/oc-probe/.opencode/plugins/probe.ts
    

    No failed to load plugin, no Cannot find package '@opencode/plugin'.

    So on 2.0.27 the host does provide @opencode/plugin to discovery-loaded plugins. The Cannot find package failure you saw may be specific to the config-directory entry path, or a platform/packaging difference (your log paths look Windows-flavoured). The first half of your report — plugins entries pointing at a .ts file rejected with configured plugin path must be a directory while the docs advertise exactly that form — reproduces identically; details on #46551.

  4. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the detailed report. Both problems you describe are already tracked:

    Possible duplicates and related issues, ordered from most to least likely:

    Until then, point the entry at the plugin's directory, which needs an index.ts/index.js, rather than at the file.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  5. opencodejr commented on Oct 29, 2026

    @opencodejr

    We haven't heard back in the last day, so I'm closing this as a duplicate. Both problems you reported are already tracked:

    Please follow those issues for updates. Your Windows reproduction would be a useful comment on either of them. If your problem turns out to be different, reply here and we can reopen.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions