Skip to content

Plugins with github: specifier fail to load on restart (cache hit path resolves wrong package name) #24437

Closed as not planned

Description

@Edison-A-N

Description

Plugins installed via github: specifier (e.g. github:Edison-A-N/opencode-agent-memory) load successfully on first launch but fail with ENOENT on every subsequent restart, until the cache directory is manually deleted.

Error from logs:

ERROR service=plugin path=github:Edison-A-N/opencode-agent-memory
  error=ENOENT: no such file or directory, open
  '~/.cache/opencode/packages/github:Edison-A-N/opencode-agent-memory/node_modules/github:Edison-A-N/package.json'
  failed to resolve plugin server entry

The expected path should be node_modules/@Edison-A-N/opencode-agent-memory/package.json, but the cache-hit code path uses the raw specifier string as the package name.

Root cause is in packages/core/src/npm.ts — the Npm.add() function:

  • First install (cache dir absent): reify() runs, then tree.edgesOut provides the correct installed path → ✅ works
  • Cache hit (cache dir exists): npa(pkg).name is used to reconstruct the path, but npa("github:user/repo") returns name: null, so it falls back to the raw spec string "github:Edison-A-N/opencode-agent-memory" → ❌ ENOENT
// packages/core/src/npm.ts — Npm.add()
const name = (() => {
  try {
    return npa(pkg).name ?? pkg  // npa("github:user/repo").name → null → falls back to raw spec
  } catch {
    return pkg
  }
})()

if (yield* afs.existsSafe(dir)) {
  // Cache hit: constructs node_modules/github:Edison-A-N/opencode-agent-memory → wrong
  return resolveEntryPoint(name, path.join(dir, "node_modules", name))
}

A possible fix: when the cache directory exists, read the dependency name from the cached package.json (written during reify) instead of relying on npa().name:

if (yield* afs.existsSafe(dir)) {
  const manifest = yield* afs.readJson(path.join(dir, "package.json")).pipe(Effect.option)
  if (Option.isSome(manifest)) {
    const deps = (manifest.value as any)?.dependencies ?? {}
    const depName = Object.keys(deps)[0]
    if (depName) {
      return resolveEntryPoint(depName, path.join(dir, "node_modules", depName))
    }
  }
  return resolveEntryPoint(name, path.join(dir, "node_modules", name))
}

Plugins

github:Edison-A-N/opencode-agent-memory

OpenCode version

1.3.13

Steps to reproduce

  1. Add plugin to config: "plugin": ["github:Edison-A-N/opencode-agent-memory"]
  2. Start opencode → plugin loads (first install via reify)
  3. Restart opencode → plugin fails with ENOENT
  4. Workaround: rm -rf ~/.cache/opencode/packages/github:Edison-A-N/opencode-agent-memory/ → works again until next restart

Screenshot and/or share link

No response

Operating System

Linux (Ubuntu)

Terminal

Ghostty

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 26, 2026
  2. prasadf18 commented on Apr 27, 2026

    @prasadf18

    @rekram1-node hi, please assign this to me

  3. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 3, 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