Skip to content

Bug: file:// plugins with same filename incorrectly deduplicated #8759

Closed as not planned

Description

@coleleavitt

Bug Description

Multiple file:// plugins with the same entry point filename (e.g., index.js) are incorrectly treated as duplicates during plugin loading, causing only the last one to load.

Steps to Reproduce

  1. Create a config with multiple file:// plugins using standard entry points:
{
  "plugin": [
    "file:///path/to/plugin-a/dist/index.js",
    "file:///path/to/plugin-b/dist/index.js",
    "file:///path/to/plugin-c/dist/index.js"
  ]
}
  1. Start OpenCode with debug logging:
OPENCODE_LOG_LEVEL=DEBUG opencode run "test" 2>&1 | grep "loading plugin"
  1. Observe that only the last plugin loads

Expected Behavior

All three plugins should load since they have different paths.

Actual Behavior

Only plugin-c loads. The deduplication logic in getPluginName() extracts only the filename ("index") for all three plugins, marking them as duplicates.

Root Cause

In packages/opencode/src/config/config.ts, the getPluginName() function extracts only the filename for file:// URLs:

if (plugin.startsWith("file://")) {
  return path.parse(new URL(plugin).pathname).name  // Returns "index" for all
}

This was designed for npm package deduplication but doesn't account for file:// plugins where:

  • Multiple plugins may use the same filename (standard practice: index.js)
  • Plugins in different directories should not be considered duplicates
  • Even plugins in the same directory with different filenames should be allowed

Impact

  • Users cannot use multiple local plugins with standard entry point names
  • No warning is shown when plugins are silently dropped
  • Workaround requires renaming entry points to unique names (non-standard)

Environment

  • OpenCode version: 1.1.23
  • Node/Bun version: Bun 1.3.5
  • OS: Linux

Related

This affects anyone using local plugin development with standard JavaScript conventions.

Activity

  1. github-actions commented on Jan 15, 2026

    @github-actions
    Contributor

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

    Feel free to ignore if none of these address your specific case.

  2. cyberprophet commented on Mar 4, 2026

    @cyberprophet
    Contributor

    This is addressed by #15598 which adds node_modules-aware path parsing to getPluginName(). CI is green.

    The root cause is that import.meta.resolve resolves npm plugins to file://…/node_modules/<pkg>/dist/index.js, and then getPluginName() extracts only the filename "index", causing false collisions with any project plugin that also has an index.ts entry point.

    Related issues: #8759, #10115, #11159, #12285, #14304, #15591

  3. added 2 commits that reference this issue on Mar 5, 2026
    b26d661
  4. github-actions commented on May 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions